Method List
Warning: The commands on this page are not thread-safe.
A - C - D - E - F - G - I - M - N - O - P - R - S
A
VP ADD FORMULA NAME
VP ADD FORMULA NAME ( vpAreaName : Text ; vpFormula : Text ; name : Text { ; options : Object } )
Parameter | Type | Description | |
---|---|---|---|
vpAreaName | Text | -> | 4D View Pro area form object name |
vpFormula | Text | -> | 4D View Pro formula |
name | Text | -> | Name for the formula |
options | Object | -> | Options for the named formula |
Description
The VP ADD FORMULA NAME
command creates or modifies a named formula in the open document.
Named formulas created by this command are saved with the document.
In vpAreaName, pass the name of the 4D View Pro area. If you pass a name that does not exist, an error is returned.
Pass the 4D View Pro formula that you want to name in vpFormula. For detailed information about formula syntax, see Formulas and Functions page.
Pass the new name for the formula in name. If the name is already used within the same scope, the new named formula replaces the existing one. Note that you can use the same name for different scopes (see below).
You can pass an object with additional properties for the named formula in options. The following properties are supported:
Property | Type | Description |
---|---|---|
scope | Number | Scope for the formula. You can pass the sheet index (counting begins at 0) or use the following constants: vk current sheet vk workbook vk current sheet ), or global across the entire workbook (scope=vk workbook ). |
comment | Text | Comment associated to named formula |
Example
VP ADD FORMULA NAME("ViewProArea";"SUM($A$1:$A$10)";"Total2")
See also
Cell references
VP Get formula by name
VP Get names
VP ADD RANGE NAME
VP ADD RANGE NAME ( rangeObj : Object ; name : Text { ; options : Object } )
Parameter | Type | Description | |
---|---|---|---|
rangeObj | Object | -> | Range object |
name | Text | -> | Name for the fomula |
options | Object | -> | Options for the named formula |
Description
The VP ADD RANGE NAME
command creates or modifies a named range in the open document.
Named ranges created by this command are saved with the document.
In rangeObj, pass the range that you want to name and in name, pass the new name for the range. If the name is already used within the same scope, the new named range replaces the existing one. Note that you can use the same name for different scopes (see below).
You can pass an object with additional properties for the named range in options. The following properties are supported:
Property | Type | Description |
---|---|---|
scope | Number | Scope for the range. You can pass the sheet index (counting begins at 0) or use the following constants: vk current sheet vk workbook vk current sheet ), or global across the entire workbook (scope=vk workbook ). |
comment | Text | Comment associated to named range |
- A named range is actually a named formula containing coordinates.
VP ADD RANGE NAME
facilitates the creation of named ranges, but you can also use theVP ADD FORMULA NAME
method to create named ranges.- Formulas defining named ranges can be retrieved with the
VP Get formula by name
method.
Example
You want to create a named range for a cell range:
$range:=VP Cell("ViewProArea";2;10)
VP ADD RANGE NAME($range;"Total1")
See also
VP ADD SELECTION
VP ADD SELECTION ( rangeObj : Object )
Parameter | Type | Description | |
---|---|---|---|
rangeObj | Text | -> | Range object |
Description
The VP ADD SELECTION
command adds the specified cells to the currently selected cells.
In rangeObj, pass a range object of cells to add to the current selection.
The active cell is not modified.
Example
You have cells currently selected:
The following code will add cells to your selection:
$currentSelection:=VP Cells("myVPArea";3;4;2;3)
VP ADD SELECTION($currentSelection)
Result:
See also
VP Get active cell
VP Get selection
VP RESET SELECTION
VP SET ACTIVE CELL
VP SET SELECTION
VP SHOW CELL
VP ADD SHEET
VP ADD SHEET ( vpAreaName : Text )
VP ADD SHEET ( vpAreaName : Text ; index : Integer )
VP ADD SHEET ( vpAreaName : Text ; sheet : Integer ; name : Text )
Parameter | Type | Description | |
---|---|---|---|
vpAreaName | Text | -> | 4D View Pro area form object name |
sheet | Integer | -> | Index of the new sheet |
name | Text | -> | Sheet name |
Description
The VP ADD SHEET
command inserts a sheet in the document loaded in vpAreaName.
In vpAreaName, pass the name of the 4D View Pro area.
In sheet, you can pass an index for the new sheet. If the passed index is inferior to or equal to 0, the command inserts the new sheet at the beginning. If index exceeds the number of sheets, the command inserts the new sheet after the existing ones.
Indexing starts at 0.
In name, you can pass a name for the new sheet. The new name cannot contain the following characters: *, :, [, ], ?,\,/
Example
The document currently has 3 sheets:
To insert a sheet at the third position (index 2) and name it "March":
VP ADD SHEET("ViewProArea";2;"March")
See also
VP ADD SPAN
VP ADD SPAN ( rangeObj : Object )
Parameter | Type | Description | |
---|---|---|---|
rangeObj | Object | -> | Range object |
Description
The VP ADD SPAN
command combines the cells in rangeObj as a single span of cells.
In rangeObj, pass a range object of cells. The cells in the range are joined to create a larger cell extending across multiple columns and/or rows. You can pass multiple cell ranges to create several spans at the same time. Note that if cell ranges overlap, only the first cell range is used.
- Only the data in the upper-left cell is displayed. Data in the other combined cells is hidden until the span is removed.
- Hidden data in spanned cells is accessible via formulas (beginning with the upper-left cell).
Example
To span the First quarter and Second quarter cells across the two cells beside them, and the South area cell across the two rows below it:
// First quarter range
$q1:=VP Cells("ViewProArea";2;3;3;1)
// Second quarter range
$q2:=VP Cells("ViewProArea";5;3;3;1)
// South area range
$south:=VP Cells("ViewProArea";0;5;1;3)
VP ADD SPAN(VP Combine ranges($q1;$q2;$south))
See also
4D View Pro Range Object Properties
VP Get spans
VP REMOVE SPAN
VP ADD STYLESHEET
VP ADD STYLESHEET ( vpAreaName : Text ; styleName : Text ; styleObj : Object { ; sheet : Integer } )
Parameter | Type | Description | |
---|---|---|---|
vpAreaName | Text | -> | 4D View Pro area form object name |
styleName | Text | -> | Name of style |
styleObj | Object | -> | Object defining attribute settings |
sheet | Integer | -> | Sheet index (current sheet if omitted) |
Description
The VP ADD STYLESHEET
command creates or modifies the styleName style sheet based upon the combination of the properties specified in styleObj in the open document. If a style sheet with the same name and index already exists in the document, this command will overwrite it with the new values.
Style sheets created by this command are saved with the document.
In vpAreaName, pass the name of the 4D View Pro area. If you pass a name that does not exist, an error is returned.
The styleName parameter lets you assign a name to the style sheet. If the name is already used within the same scope, the new style sheet replaces the existing one. Note that you can use the same name for different scopes (see below).
Within the styleObj, designate the settings for the style sheet (e.g., font, text decoration, alignment, borders, etc.). For the full list of style properties, see Style object properties.
You can designate where to define the style sheet in the optional sheet parameter using the sheet index (indexing starts at 0) or with the following constants:
vk current sheet
vk workbook
If a styleName style sheet is defined at the workbook level and at a sheet level, the sheet level has priority over the workbook level when the style sheet is set.
To apply the style sheet, use the VP SET DEFAULT STYLE or VP SET CELL STYLE commands.
Example
The following code:
$styles:=New object
$styles.backColor:="green"
//Line Border Object
$borders:=New object("color";"green";"style";vk line style medium dash dot)
$styles.borderBottom:=$borders
$styles.borderLeft:=$borders
$styles.borderRight:=$borders
$styles.borderTop:=$borders
VP ADD STYLESHEET("ViewProArea";"GreenDashDotStyle";$styles)
//To apply the style
VP SET CELL STYLE(VP Cells("ViewProArea";1;1;2;2);New object("name";"GreenDashDotStyle"))
will create and apply the following style object named GreenDashDotStyle:
{
backColor:green,
borderBottom:{color:green,style:10},
borderLeft:{color:green,style:10},
borderRight:{color:green,style:10},
borderTop:{color:green,style:10}
}
See also
4D View Pro Style Objects and Style Sheets
VP Get stylesheet
VP Get stylesheets
VP REMOVE STYLESHEET
VP SET CELL STYLE
VP SET DEFAULT STYLE
VP All
VP All ( vpAreaName : Text { ; sheet : Integer } ) : Object
Parameter | Type | Description | |
---|---|---|---|
vpAreaName | Text | -> | 4D View Pro area form object name |
sheet | Integer | -> | Sheet index (current sheet if omitted) |
Result | Object | <- | Range object of all cells |
Description
The VP ALL
command returns a new range object referencing all cells.
In vpAreaName, pass the name of the 4D View Pro area. If you pass a name that does not exist, an error is returned.
In the optional sheet parameter, you can designate a specific spreadsheet where the range will be defined (counting begins at 0). If omitted or if you pass vk current sheet
, the current spreadsheet is used.
Example
You want to define a range object for all of the cells of the current spreadsheet:
$all:=VP All("ViewProArea") // all cells of the current sheet
See also
VP Cell
VP Cells
VP Column
VP Combine ranges
VP Name
VP Row
C
VP Cell
VP Cell ( vpAreaName ; column : Integer ; row : Integer ; Text { ; sheet : Integer } ) : Object
Parameter | Type | Description | |
---|---|---|---|
vpAreaName | Text | -> | 4D View Pro area form object name |
column | Longint | -> | Column index |
row | Longint | -> | Row index |
sheet | Integer | -> | Sheet index (current sheet if omitted) |
Result | Object | <- | Range object of a single cell |
Description
The VP Cell
command returns a new range object referencing a specific cell.
This command is intended for ranges of a single cell. To create a range object for multiple cells, use the VP Cells command.
In vpAreaName, pass the name of the 4D View Pro area. If you pass a name that does not exist, an error is returned.
The column parameter defines the column of the cell range's position. Pass the column index in this parameter.
The row parameter defines the row of the cell range's position. Pass the row index in this parameter.
In the optional sheet parameter, you can indicate the index of the sheet where the range will be defined. If omitted or if you pass vk current sheet
, the current spreadsheet is used by default.
indexing starts at 0.
Example
You want to define a range object for the cell shown below (on the current spreadsheet):
The code would be:
$cell:=VP Cell("ViewProArea";2;4) // C5
See also
VP All
VP Cells
VP Column
VP Combine ranges
VP Name
VP Row
VP Cells
VP Cells ( vpAreaName : Text ; column: Integer ; row: Integer ; columnCount : Integer ; rowCount : Integer { ; sheet : Integer } ) : Object
History
Release | Changes |
---|---|
17 R4 | Added |
Parameter | Type | Description | |
---|---|---|---|
vpAreaName | Text | -> | 4D View Pro area form object name |
column | Integer | -> | Column index |
row | Integer | -> | Row index |
columnCount | Integer | -> | Number of columns |
rowCount | Integer | -> | Number of rows |
sheet | Integer | -> | Sheet index (current sheet if omitted) |
Result | Object | <- | Range object of cells |
Description
The VP Cells
command returns a new range object referencing specific cells.
In vpAreaName, pass the name of the 4D View Pro area. If you pass a name that does not exist, an error is returned.
The column parameter defines the first column of the cell range. Pass the column index (counting begins at 0) in this parameter. If the range is within multiple columns, you should also use the columnCount parameter.
In the row parameter, you can define the row(s) of the cell range's position. Pass the row index (counting begins at 0) in this parameter. If the range is within multiple rows, you should also use the rowCount parameter.
The columnCount parameter allows you to define the total number of columns the range is within. columnCount must be greater than 0.
The rowCount parameter allows you to define the total number of rows the range is within. rowCount must be greater than 0.
In the optional sheet parameter, you can designate a specific spreadsheet where the range will be defined (counting begins at 0). If omitted or if you pass vk current sheet
, the current spreadsheet is used by default.
Example
You want to define a range object for the following cells (on the current sheet):
The code would be:
$cells:=VP Cells("ViewProArea";2;4;2;3) // C5 to D7
See also
VP All
VP Cells
VP Column
VP Combine ranges
VP Name
VP Row
VP Column
VP Column ( vpAreaName : Text ; column: Integer ; columnCount : Integer { ; sheet : Integer } ) : Object
Parameter | Type | Description | |
---|---|---|---|
vpAreaName | Text | -> | 4D View Pro area form object name |
column | Integer | -> | Column index |
columnCount | Integer | -> | Number of columns |
sheet | Integer | -> | Sheet index (current sheet if omitted) |
Result | Object | <- | Range object of cells |
Description
The VP Column
command returns a new range object referencing a specific column or columns.
In vpAreaName, pass the name of the 4D View Pro area. If you pass a name that does not exist, an error is returned.
The column parameter defines the first column of the column range. Pass the column index (counting begins at 0) in this parameter. If the range contains multiple columns, you should also use the optional columnCount parameter.
The optional columnCount parameter allows you to define the total number of columns of the range. columnCount must be greater than 0. If omitted, the value will be set to 1 by default and a column type range is created.
In the optional sheet parameter, you can designate a specific spreadsheet where the range will be defined (counting begins at 0). If omitted or if you pass vk current sheet
, the current spreadsheet is used by default.
Example
You want to define a range object for the column shown below (on the current spreadsheet):
The code would be:
$column:=VP Column("ViewProArea";3) // column D
See also
VP All
VP Cells
VP Column
VP Combine ranges
VP Name
VP Row
VP SET COLUMN ATTRIBUTES
VP COLUMN AUTOFIT
VP COLUMN AUTOFIT ( rangeObj : Object )
Parameter | Type | Description | |
---|---|---|---|
rangeObj | Object | -> | Range object |
Description
The VP COLUMN AUTOFIT
command automatically sizes the column(s) in rangeObj according to their contents.
In rangeObj, pass a range object containing a range of the columns whose size will be automatically handled.
Example
The following columns are all the same size and don't display some of the text:
Selecting the columns and running this code:
VP COLUMN AUTOFIT(VP Get selection("ViewProarea"))
... resizes the columns to fit the size of the contents:
See also
VP Combine ranges
VP Combine ranges ( rangeObj : Object ; otherRangeObj : Object {;...otherRangeObjN : Object } ) : Object
Parameter | Type | Description | |
---|---|---|---|
rangeObj | Object | -> | Range object |
otherRangeObj | Object | -> | Range object |
Result | Object | <- | Object containing a combined range |
Description
The VP Combine Ranges
command returns a new range object that incorporates two or more existing range objects. All of the ranges must be from the same 4D View Pro area.
In rangeObj, pass the first range object.
In otherRangeObj, pass another range object(s) to combine with rangeObj.
The command incorporates rangeObj and otherRangeObj objects by reference.
Example
You want to combine cell, column, and row range objects in a new, distinct range object:
$cell:=VP Cell("ViewProArea";2;4) // C5
$column:=VP Column("ViewProArea";3) // column D
$row:=VP Row("ViewProArea";9) // row 10
$combine:=VP Combine ranges($cell;$column;$row)
See also
VP All
VP Cells
VP Column
VP Combine ranges
VP Name
VP Row
VP SET COLUMN ATTRIBUTES
VP Convert from 4D View
VP Convert from 4D View ( 4DViewDocument : Blob ) : Object
Parameter | Type | Description | |
---|---|---|---|
4DViewDocument | Blob | -> | 4D View document |
Result | Object | <- | 4D View Pro object |
Description
The VP Convert from 4D View
command allows you to convert a legacy 4D View document into a 4D View Pro object.
This command does not require that the legacy 4D View plug-in be installed in your environment.
In the 4DViewDocument parameter, pass a BLOB variable or field containing the 4D View document to convert. The command returns a 4D View Pro object into which all the information originally stored within the 4D View document is converted to 4D View Pro attributes.
Example
You want to get a 4D View Pro object from a 4D View area stored in a BLOB:
C_OBJECT($vpObj)
$vpObj:=VP Convert from 4D View($pvblob)
VP Convert to picture
VP Convert to picture ( vpObject : Object {; rangeObj : Object} ) : Picture
Parameter | Type | Description | |
---|---|---|---|
vpObject | Object | -> | 4D View Pro object containing the area to convert |
rangeObj | Object | -> | Range object |
Result | Picture | <- | SVG picture of the area |
Description
The VP Convert to picture
command converts the vpObject 4D View Pro object (or the rangeObj range within vpObject) to a SVG picture.
This command is useful, for example:
- to embed a 4D View Pro document in an other document such as a 4D Write Pro document
- to print a 4D View Pro document without having to load it into a 4D View Pro area.
In vpObject, pass the 4D View Pro object that you want to convert. This object must have been previously parsed using VP Export to object or saved using VP EXPORT DOCUMENT.
SVG conversion process requires that expressions and formats (cf. Cell Format) included in the 4D View Pro area be evaluated at least once, so that they can be correctly exported. If you convert a document that was not evaluated beforehand, expressions or formats may be rendered in an unexpected way.
In rangeObj, pass a range of cells to convert. By default, if this parameter is omitted, the whole document contents are converted.
Document contents are converted with respect to their viewing attributes, including formats (see note above), visibility of headers, columns and rows. The conversion of the following elements is supported:
- Text : style / font / size / alignment / orientation / rotation / format
- Cell background : color / image
- Cell borders : thickness / color / style
- Cell merge
- Pictures
- Row height
- Column width
- Hidden columns / rows.
Gridline visibility depends on document attribute defined with VP SET PRINT INFO.
Function result
The command returns a picture in SVG format.
Example
You want to convert a 4D View Pro area in SVG, preview the result, and send it to a picture variable:
C_OBJECT($vpAreaObj)
C_PICTURE($vPict)
$vpAreaObj:=VP Export to object("ViewProArea")
$vPict:=VP Convert to picture($vpAreaObj) //export the whole area
See also
VP EXPORT DOCUMENT
VP Export to object
VP SET PRINT INFO
VP Copy to object
History
Release | Changes |
---|---|
19 R4 | Added |
VP Copy to object ( rangeObj : Object {; options : Object} ) : Object
Parameter | Type | Description | |
---|---|---|---|
rangeObj | Object | -> | Range object |
options | Object | -> | Additional options |
Result | Object | <- | Object returned. Contains the copied data |
Description
The VP Copy to object
command copies the contents, style and formulas from rangeObj to an object.
In rangeObj, pass the cell range with the values, formatting, and formulas to copy. If rangeObj is a combined range, only the first one is used.
You can pass an optional options parameter with the following properties:
Property | Type | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
copy | Boolean | True (default) to keep the copied values, formatting and formulas after the command executes. False to remove them. | ||||||||||||||
copyOptions | Longint | Specifies what is copied or moved. Possible values:
|
The paste options defined in the workbook options are taken into account.
The command returns an object that contains the copied data.
Example
This code sample first stores the contents, values, formatting and formulas from a range to an object, and then pastes them in another range:
var $originRange; $targetRange; $dataObject; $options : Object
$originRange:=VP Cells("ViewProArea"; 0; 0; 2; 5)
$options:=New object
$options.copy:=True
$options.copyOptions:=vk clipboard options all
$dataObject:=VP Copy to object($originRange; $options)
$targetRange:=VP Cell("ViewProArea"; 4; 0)
VP PASTE FROM OBJECT($targetRange; $dataObject; vk clipboard options all)
See also
VP PASTE FROM OBJECT
VP MOVE CELLS
VP Get workbook options
VP SET WORKBOOK OPTIONS
VP CREATE TABLE
History
Release | Changes |
---|---|
19 R8 | Support of theme options: bandColumns , bandRows , highlightFirstColumn , highlightLastColumn , theme |
19 R7 | Support of allowAutoExpand option |
19 R6 | Added |
VP CREATE TABLE ( rangeObj : Object ; tableName : Text {; source : Text} {; options : cs.ViewPro.TableOptions} )
Parameter | Type | Description | |
---|---|---|---|
rangeObj | Object | -> | Range object |
tableName | Text | -> | Name for the table |
source | Text | -> | Data context property name to display in the table |
options | cs.ViewPro.TableOptions | -> | Additional options |
Description
The VP CREATE TABLE
command creates a table in the specified range. You can create a table in a range of cells to make managing and analyzing a group of related data easier. A table typically contains related data in rows and columns, and takes advantage of a data context.
In rangeObj, pass the cell range where the table will be created.
In tableName, pass a name for the table. The name must:
- be unique in the sheet
- include at least 5 characters
- not include spaces or start with a number
In source, you can pass a property name of a data context to display its data in the table. This binds the table to the data context. When the data context is updated, the data displayed in the table is updated accordingly. The source property must contain a collection of objects and each element represents a row.
- If you don't specify a source, the command creates an empty table with the size defined in rangeObj.
- If the specified source cannot be fully displayed in the document, no table is created.
In the options parameter, pass an object of the cs.ViewPro.TableOptions
class that contains the table properties to set.
Within the options object, the tableColumns collection determines the structure of the table's columns. The length of the tableColumns collection must be equal to the range column count:
- When the column count in rangeObj exceeds the number of columns in tableColumns, the table is filled with additional empty columns.
- When the column count in rangeObj is inferior to the number of tableColumns, the table displays a number of columns that match the range's column count.
If you pass a source but no tableColumn option, the command generates columns automatically. In this case, rangeObj must be a cell range. Otherwise, the first cell of the range is used. When generating columns automatically, the following rules apply:
- If the data passed to the command is a collection of objects, the property names are used as column titles. For example:
([{ LastName: \"Freehafer\", FirstName: \"Nancy\"},{ LastName: \"John\", FirstName: \"Doe\"})
Here the titles of the columns would be LastName
and FirstName
.
-
If the data passed to the command is a collection of scalar values, it must contain a collection of subcollections:
- The first-level collection contains subcollections of values. Each subcollection defines a row. Pass an empty collection to skip a row. The number of values in the first subcollection determines how many columns are created.
- The subcollections' indices are used as column titles.
- Each subcollection defines cell values for the row. Values can be
Integer
,Real
,Boolean
,Text
,Date
,Null
,Time
orPicture
. ATime
value must be an a object containing a time attribute, as described in VP SET VALUE.
This only works when generating columns automatically. You cannot use a collection of scalar data with the tableColumns option.
Example
To create a table using a data context:
// Set a data context
var $data : Object
$data:=New object()
$data.people:=New collection()
$data.people.push(New object("firstName"; "John"; "lastName"; "Smith"; "email"; "johnsmith@gmail.com"))
$data.people.push(New object("firstName"; "Mary"; "lastName"; "Poppins"; "email"; "marypoppins@gmail.com"))
VP SET DATA CONTEXT("ViewProArea"; $data)
// Define the columns for the table
var $options : cs.ViewPro.TableOptions
$options:=cs.ViewPro.TableOptions.new()
$options.tableColumns:=New collection()
$options.tableColumns.push(cs.ViewPro.TableColumns.new("name"; "First name"; "dataField"; "firstName"))
$options.tableColumns.push(cs.ViewPro.TableColumns.new("name"; "Last name"; "dataField"; "lastName"))
$options.tableColumns.push(cs.ViewPro.TableColumns.new("name"; "Email"; "dataField"; "email"))
// Create a table from the "people" collection
VP CREATE TABLE(VP Cells("ViewProArea"; 1; 1; $options.tableColumns.length; 1); "ContextTable"; "people"; $options)
Here's the result:
See also
VP Find table
VP Get table column attributes
VP Get table column index
VP INSERT TABLE COLUMNS
VP INSERT TABLE ROWS
VP REMOVE TABLE
VP RESIZE TABLE
VP SET DATA CONTEXT
VP SET TABLE COLUMN ATTRIBUTES
VP SET TABLE THEME
D
VP DELETE COLUMNS
VP DELETE COLUMNS ( rangeObj : Object )
Parameter | Type | Description | |
---|---|---|---|
rangeObj | Object | -> | Range object |
Description
The VP DELETE COLUMNS
command removes the columns in the rangeObj.
In rangeObj, pass an object containing a range of columns to remove. If the passed range contains:
- both columns and rows, only the columns are removed.
- only rows, the command does nothing.
Columns are deleted from right to left.
Example
To delete columns selected by the user (in the image below columns B, C, and D):
use the following code:
VP DELETE COLUMNS(VP Get selection("ViewProArea"))
See also
VP DELETE ROWS
VP DELETE ROWS ( rangeObj : Object )
Parameter | Type | Description | |
---|---|---|---|
rangeObj | Object | -> | Range object |
Description
The VP DELETE ROWS
command removes the rows in the rangeObj.
In rangeObj, pass an object containing a range of rows to remove. If the passed range contains:
- both columns and rows, only the rows are removed.
- only columns, the command does nothing.
Rows are deleted from bottom to top.
Example
To delete rows selected by the user (in the image below rows 1, 2, and 3):
use the following code:
VP DELETE ROWS(VP Get selection("ViewProArea"))
See also
E
VP EXPORT DOCUMENT
VP EXPORT DOCUMENT ( vpAreaName : Text ; filePath : Text {; paramObj : Object} )
Parameter | Type | Description | |
---|---|---|---|
vpAreaName | Text | -> | 4D View Pro area form object name |
filePath | Text | -> | Pathname of the document |
paramObj | Object | -> | Export options |
Description
The VP EXPORT DOCUMENT
command exports the 4D View Pro object attached to the 4D View Pro area vpAreaName to a document on disk according to the filePath and paramObj parameters.
In vpAreaName, pass the name of the 4D View Pro area. If you pass a name that does not exist, an error is returned.
In filePath, pass the destination path and name of the document to be exported. If you don't specify a path, the document will be saved at the same level as the Project folder.
You can specify the exported file's format by including an extension after the document's name:
- 4D View Pro (".4vp")
- Microsoft Excel (".xlsx")
- PDF (".pdf")
- CSV (".txt", or ".csv")
If the extension is not included, but the format is specified in paramObj, the exported file will have the extension that corresponds to the format, except for the CSV format (no extension is added in this case).
The optional paramObj parameter allows you to define multiple properties for the exported 4D View Pro object, as well as launch a callback method when the export has completed.
Property | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
format | text | (optional) When present, designates the exported file format: ".4vp" (default), ".csv", ".xlsx", or ".pdf". You can use the following constants:vk 4D View Pro format vk csv format vk MS Excel format vk pdf format | ||||||||||||||||||
password | text | Microsoft Excel only (optional) - Password used to protect the MS Excel document | ||||||||||||||||||
formula | object | Callback method to be launched when the export has completed. Using a callback method is necessary when the export is asynchronous (which is the case for PDF and Excel formats) if you need some code to be executed after the export. The callback method must be used with the Formula command (see below for more information). | ||||||||||||||||||
valuesOnly | boolean | Specifies that only the values from formulas (if any) will be exported. | ||||||||||||||||||
includeFormatInfo | boolean | True to include formatting information, false otherwise (default is true). Formatting information is useful in some cases, e.g. for export to SVG. On the other hand, setting this property to false allows reducing export time. | ||||||||||||||||||
includeBindingSource | Boolean | 4DVP and Microsoft Excel only. True (default) to export the current data context values as cell values in the exported document (data contexts themselves are not exported). False otherwise. Cell binding is always exported. For data context and cell binding management, see VP SET DATA CONTEXT and VP SET BINDING PATH. | ||||||||||||||||||
sheetIndex | number | PDF only (optional) - Index of sheet to export (starting from 0). -2=all visible sheets (default), -1=current sheet only | ||||||||||||||||||
pdfOptions | object | PDF only (optional) - Options for pdf export
| ||||||||||||||||||
csvOptions | object | CSV only (optional) - Options for csv export
| ||||||||||||||||||
\<customProperty> | any | Any custom property that will be available through the $3 parameter in the callback method. |
Notes about Excel format:
- When exporting a 4D View Pro document into a Microsoft Excel-formatted file, some settings may be lost. For example, 4D methods and formulas are not supported by Excel. You can verify other settings with this list from GrapeCity.
- Exporting in this format is run asynchronously, use the formula property of the paramObj for code to be executed after the export.
Notes about PDF format:
- When exporting a 4D View Pro document in PDF, the fonts used in the document are automatically embedded in the PDF file. Only OpenType fonts (.OTF or .TTF files) having a Unicode map can be embedded. If no valid font file is found for a font, a default font is used instead.
- Exporting in this format is run asynchronously, use the formula property of the paramObj for code to be executed after the export.
Notes about CSV format:
- When exporting a 4D View Pro document to CSV, some settings may be lost, as only the text and values are saved.
- All the values are saved as double-quoted strings. For more information on delimiter-separated values, see this article on Wikipedia.
Once the export operation is finished, VP EXPORT DOCUMENT
automatically triggers the execution of the method set in the formula property of the paramObj, if used.
Passing a callback method (formula)
When including the optional paramObj parameter, the VP EXPORT DOCUMENT
command allows you to use the Formula
command to call a 4D method which will be executed once the export has completed. The callback method will receive the following values in local variables:
Variable | Type | Description | |
---|---|---|---|
$1 | text | The name of the 4D View Pro area object | |
$2 | text | The filepath of the exported 4D View Pro object | |
$3 | object | A reference to the command's paramObj | |
$4 | object | An object returned by the method with a status message | |
.success | boolean | True if export with success, False otherwise. | |
.errorCode | integer | Error code. May be returned by 4D or JavaScript. | |
.errorMessage | text | Error message. May be returned by 4D or JavaScript. |
Example 1
You want to export the contents of the "VPArea" area to a 4D View Pro document on disk:
var $docPath: Text
$docPath:="C:\\Bases\\ViewProDocs\\MyExport.4VP"
VP EXPORT DOCUMENT("VPArea";$docPath)
//MyExport.4VP is saved on your disk
Example 2
You want to export the current sheet in PDF:
var $params: Object
$params:=New object
$params.format:=vk pdf format
$params.sheetIndex:=-1
$params.pdfOptions:=New object("title";"Annual Report";"author";Current user)
VP EXPORT DOCUMENT("VPArea";"report.pdf";$params)
Example 3
You want to export a 4D View Pro document in ".xlsx" format and call a method that will launch Microsoft Excel with the document open once the export has completed:
$params:=New object
$params.formula:=Formula(AfterExport)
$params.format:=vk MS Excel format //".xlsx"
$params.valuesOnly:=True
VP EXPORT DOCUMENT("ViewProArea";"c:\\tmp\\convertedfile";$params)
AfterExport method:
C_TEXT($1;$2)
C_OBJECT($3;$4)
$areaName:=$1
$filePath:=$2
$params:=$3
$status:=$4
If($status.success=False)
ALERT($status.errorMessage)
Else
LAUNCH EXTERNAL PROCESS("C:\\Program Files\\Microsoft Office\\Office15\\excel "+$filePath)
End if
Example 4
You want to export the current sheet to a .txt
file with pipe-separated values:
var $params : Object
$params:=New object
$params.range:=VP Cells("ViewProArea";0;0;2;5)
$params.rowDelimiter:="\n"
$params.columnDelimiter:="|"
VP EXPORT DOCUMENT("ViewProArea";"c:\\tmp\\data.txt";New object("format";vk csv format;"csvOptions";$params))
Here's the result:
See also
VP Convert to picture
VP Export to object
VP Column
VP Print
VP Export to object
VP Export to object ( vpAreaName : Text {; options : Object} ) : Object
Parameter | Type | Description | |
---|---|---|---|
vpAreaName | Text | -> | 4D View Pro area form object name |
options | Object | -> | Export options |
Result | Object | <- | 4D View Pro object |
Description
The VP Export to object
command returns the 4D View Pro object attached to the 4D View Pro area vpAreaName. You can use this command for example to store the 4D View Pro area in a 4D database object field.
In vpAreaName, pass the name of the 4D View Pro area. If you pass a name that does not exist, an error is returned.
In the options parameter, you can pass the following export options, if required:
Property | Type | Description |
---|---|---|
includeFormatInfo | Boolean | True (default) to include formatting information, false otherwise. Formatting information is useful in some cases, e.g. for export to SVG. On the other hand, setting this property to False allows reducing export time. |
includeBindingSource | Boolean | True (default) to export the current data context values as cell values in the exported object (data contexts themselves are not exported). False otherwise. Cell binding is always exported. |
For more information on 4D View Pro objects, please refer to the 4D View Pro object paragraph.
Example 1
You want to get the "version" property of the current 4D View Pro area:
var $vpAreaObj : Object
var $vpVersion : Number
$vpAreaObj:=VP Export to object("vpArea")
// $vpVersion:=OB Get($vpAreaObj;"version")
$vpVersion:=$vpAreaObj.version
Example 2
You want to export the area, excluding formatting information:
var $vpObj : Object
$vpObj:=VP Export to object("vpArea";New object("includeFormatInfo";False))
See also
VP Convert to picture
VP EXPORT DOCUMENT
VP IMPORT FROM OBJECT
F
VP Find
VP Find ( rangeObj : Object ; searchValue : Text ) : Object
VP Find ( rangeObj : Object ; searchValue : Text ; searchCondition : Object } ) : Object
VP Find ( rangeObj : Object ; searchValue : Text ; searchCondition : Object ; replaceValue : Text ) : Object
Parameter | Type | Description | |
---|---|---|---|
rangeObj | Object | -> | Range object |
searchValue | Text | -> | Search value |
searchCondition | Object | -> | Object containing search condition(s) |
replaceValue | Text | -> | Replacement value |
Result | Object | <- | Range object |
Description
The VP Find
command searches the rangeObj for the searchValue. Optional parameters can be used to refine the search and/or replace any results found.
In the rangeObj parameter, pass an object containing a range to search.
The searchValue parameter lets you pass the text to search for within the rangeObj.
You can pass the optional searchCondition parameter to specify how the search is performed. The following properties are supported:
Property | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
afterColumn | Integer | The number of the column just before the starting column of the search. If the rangeObj is a combined range, the column number given must be from the first range. Default value: -1 (beginning of the rangeObj) | ||||||||
afterRow | Integer | The number of the row just before the starting row of the search. If the rangeObj is a combined range, the row number given must be from the first range. Default value: -1 (beginning of the rangeObj) | ||||||||
all | Boolean | |||||||||
flags | Integer |
$search.flags:=vk find flag use wild cards+vk find flag ignore case | ||||||||
order | Integer |
| ||||||||
target | Integer |
These flags can be combined. For example: |
In the optional replaceValue parameter, you can pass text to take the place of any instance of the text in searchValue found in the rangeObj.
Returned Object
The function returns a range object describing each search value that was found or replaced. An empty range object is returned if no results are found.
Example 1
To find the first cell containing the word "Total":
var $range;$result : Object
$range:=VP All("ViewProArea")
$result:=VP Find($range;"Total")
Example 2
To find "Total" and replace it with "Grand Total":
var $range;$condition;$result : Object
$range:=VP All("ViewProArea")
$condition:=New object
$condition.target:=vk find target text
$condition.all:=True //Search entire document
$condition.flags:=vk find flag exact match
// Replace the cells containing only 'Total' in the current sheet with "Grand Total"
$result:=VP Find($range;"Total";$condition;"Grand Total")
// Check for empty range object
If($result.ranges.length=0)
ALERT("No result found")
Else
ALERT($result.ranges.length+" results found")
End if
VP Find table
History
Release | Changes |
---|---|
19 R7 | Added |
VP Find table ( rangeObj : Object ) : Text
Parameter | Type | Description | |
---|---|---|---|
rangeObj | Object | -> | Cell range |
Result | Text | <- | Table name |
Description
The VP Find table
command returns the name of the table to which to the rangeObj cell belongs.
In rangeObj, pass a cell range object. If the designated cells do not belong to a table, the command returns an empty string.
If rangeObj is not a cell range or contains multiple ranges, the first cell of the first range is used.
Example
If (FORM Event.code=On After Edit && FORM Event.action="valueChanged")
$tableName:=VP Find table(FORM Event.range)
If ($tableName#"")
ALERT("The "+$tableName+" table has been modified.")
End if
End if
See also
VP FLUSH COMMANDS
VP FLUSH COMMANDS ( vpAreaName : Text )
Parameter | Type | Description | |
---|---|---|---|
vpAreaName | Text | -> | 4D View Pro area form object name |