EXPORT operator
The EXPORT operator: creates an action that exports specified properties to a file, or, in common case, that opens a form in a structured view.
Syntax
EXPORT [exportFormat] FROM [columnId1 =] propertyExpr1, ..., [columnIdN = ] propertyExprN
[WHERE whereExpr] [ORDER orderExpr1 [DESC], ..., orderExprL [DESC]]
[TOP topExpr] [OFFSET offsetExpr] [TO propertyId]
EXPORT formName [OBJECTS objName1 = expr1, ..., objNameK = exprK] [exportFormat]
[TOP topSelect]
[OFFSET offsetSelect]
[TO exportTo]
Where topSelect and offsetSelect are defined either as a single expression or as a mapping by object groups:
topExpr
topGroupId1 = topPropertyExpr1, ..., topGroupIdT = topPropertyExprT
offsetExpr
offsetGroupId1 = offsetPropertyExpr1, ..., offsetGroupIdF = offsetPropertyExprF
And exportTo — either as a single destination property or as a mapping by object groups:
propertyId
groupId1 = propertyId1, ..., groupIdM = propertyIdM
exportFormat can be specified by one of the following options:
JSON [CHARSET charsetStr]
XML [HEADER | NOHEADER] [ROOT rootExpr] [TAG tagExpr] [ATTR] [CHARSET charsetStr]
CSV [separator] [HEADER | NOHEADER] [ESCAPE | NOESCAPE] [CHARSET charsetStr]
XLS [SHEET sheetExpr] [HEADER | NOHEADER]
XLSX [SHEET sheetExpr] [HEADER | NOHEADER]
DBF [CHARSET charsetStr]
TABLE
Description
The EXPORT operator creates an action that exports data from the specified properties or form to a file. The following file formats are supported: XML, JSON, CSV, XLS, XLSX, DBF, TABLE.
If no export file format is specified, it is considered to be JSON.
If the property to which the data is exported is of class FILE, then the extension of the resulting file is determined depending on the format as follows:
| Format | Extension |
|---|---|
| JSON | json |
| XML | xml |
| CSV | csv |
| XLS | xls |
| XLSX | xlsx |
| DBF | dbf |
| TABLE | table |
When exporting a form in an OBJECTS block, it is possible to add extra filters to check for the equality of the objects on the form with the values passed. These objects will not participate in building the object group hierarchy.
When a form is exported to a hierarchical format (JSON, XML), a single file is generated and written to the propertyId property. For flat formats (CSV, XLS, XLSX, DBF, TABLE) each object group is exported to its own file, so the destinations are specified as a list per object group (groupId = propertyId) — not necessarily for all groups: groups not listed are not exported. A form cannot be exported to a single file in a flat format.
Parameters
Source of export
-
formNameThe name of the form from which you want to export data. Composite ID.
-
objName1 ... objNameKNames of form objects for which filtered (fixed) values are specified. Simple IDs.
-
expr1 ... exprKExpressions whose values determine the filtered (fixed) values for form objects.
-
propertyExpr1, ..., propertyExprNList of expressions from whose values the data is exported. Each property is mapped to a table column of the result file.
-
columnId1, ..., columnIdNA list of column IDs in the resulting file into which data from the corresponding property will be exported. Each list element is either a simple ID or a string literal. If no ID is specified, it is considered equal to
expr<Column number>by default. -
whereExprAn expression whose value is a condition for the export. If not specified, it is considered equal to the disjunction of all exported properties (that is, at least one of the properties must be non-
NULL). -
orderExpr1, ..., orderExprLList of expressions by which the exported data is sorted. The expressions are arbitrary: they do not have to be present in the list
propertyExpr1, ..., propertyExprN. A sort expression is added to the internal query as a hidden column and does not appear in the export result. -
DESCKeyword. Specifies reverse sort order. By default, ascending sort is used.
-
topExprExpression whose value limits the export to its first records.
-
topGroupId1 ... topGroupIdTForm object group simple IDs for which the limit is set per group object instead of for the whole export.
-
topPropertyExpr1 ... topPropertyExprTExpressions whose values limit the records of the corresponding group objects.
-
offsetExprExpression whose value skips that many leading records of the export.
-
offsetGroupId1 ... offsetGroupIdFForm object group simple IDs for which the offset is set per group object instead of for the whole export.
-
offsetPropertyExpr1 ... offsetPropertyExprFExpressions whose values set the offset of the corresponding group objects.
Export format
-
rootExprExpression whose value is used as the name of the root XML element. The value of the expression must be of a string class. If not specified, the name of the exported form is used (
exportwhen properties are exported directly). Only applicable for export to XML. -
tagExprExpression whose value is used as the name of the XML element that wraps each exported record. The value of the expression must be of a string class. If not specified, the name of the exported form's object group is used. Only applicable for export to XML.
-
ATTRA keyword that specifies that values should be exported to the attributes of the parent tag. If not specified, the values are exported to child tags. Only applicable for export to XML.
-
separatorDelimiter in a CSV file. String literal. If not specified, then the default delimiter is
;. -
HEADER | NOHEADERKeywords specifying the presence (
HEADER) or absence (NOHEADER) of a header string in a CSV, XLS, or XLSX file. The default isNOHEADER.When using the
NOHEADERoption if the column name is one of the predefined names (A,B, ...,Z,AA, ...,AE), it is exported to the column with the corresponding number, and the following columns are exported to the columns next in order after this column.Has other meaning for XML: with
HEADERresult file contains first string like<?xml version="1.0" encoding="UTF-8"?>. Export withNOHEADERexports without this string. The default isHEADER. -
ESCAPE | NOESCAPEKeywords specifying the presence (
ESCAPE) or absence (NOESCAPE) of escaping for special characters (\r,\n,"(double quotes) and the specified delimiter (separator) in a CSV file. It makes sense to useNOESCAPEonly in cases where the specified delimiter is guaranteed not to occur in the data. The default isESCAPE. -
CHARSET charsetStrAn option specifying the encoding used for export.
-
charsetStrString literal that defines the encoding. Default value for
JSON,XML,CSVisUTF-8, forDBFisCP1251.
-
-
sheetExprExpression whose value is used as the name of the sheet in the exported file. It is used for
XLSandXLSXexport formats.
Date and time class values in text formats (JSON, XML, CSV) are written as strings, by default in ISO 8601 formats (for example, 2026-08-17, 2026-08-17T12:34:56; ZDATETIME values — the instant in UTC with the Z suffix). This behavior is defined by the useISOTimeFormatsInIntegration working parameter: when it is off, the formats of the current locale are used. In the XLS and XLSX formats such values are written as typed date/time values, not as strings. In the DBF format, DATE and DATETIME values are written to a date field (the time part of DATETIME is lost), while TIME is written as an HH:mm:ss string.
Export destination
-
propertyIdProperty ID to which the generated file will be written. This property must not have parameters and its value must be of a file class (
FILE,RAWFILE,JSONFILE, etc.). If this property is not specified, theSystem.exportFileproperty is used by default. When exporting a form, applicable only for hierarchical formats (JSON, XML). -
groupId1, ..., groupIdMNames of object groups from the exported form for which you want to export data. Simple IDs. Used only for exporting forms to flat formats.
-
propertyId1 , ..., propertyIdMProperty IDs to which the generated files for specified object groups will be written. These properties must not have parameters and their value must be of file classes (
FILE,RAWFILE,JSONFILE, etc.). Used only for exporting forms to flat formats. For the empty group of objects, the namerootis used.
Examples
CLASS Store;
name = DATA STRING[20] (Sku);
weight = DATA NUMERIC[10,2] (Sku);
in = DATA BOOLEAN (Store, Sku);
exportSkus (Store store) {
// uploading to DBF all Sku for which in (Store, Sku) is specified for the desired warehouse
EXPORT DBF CHARSET 'CP866' FROM id(Sku s), name(s), weight(s) WHERE in(store, s);
// uploads to CSV without header line and escaping special characters
EXPORT CSV NOHEADER NOESCAPE FROM id(Sku s), name(s), weight(s) WHERE in(store, s);
// uploads JSON, sorting by property name[Sku] in descending order
EXPORT FROM id(Sku s), name(s), weight(s) WHERE in(store, s) ORDER name(s) DESC;
// uploads JSON {"ff":"HI"}, as by default it gets the name value, and the platform
// gets the object {"value":"HI"} to "HI"
EXPORT FROM ff='HI';
// uploads JSON "HI", as by default it gets the name value, and the platform
// automatically converts the object {"value": "HI"} to "HI"
EXPORT FROM 'HI';
}
FORM exportSku
OBJECTS st = Store
OBJECTS s = Sku
PROPERTIES(s) id, name, weight
FILTERS in(st, s)
;
exportSku (Store store) {
// uploading to DBF all Sku for which in (Store, Sku) is specified for the desired warehouse
// flat format: the file is specified for the object group s
EXPORT exportSku OBJECTS st = store DBF CHARSET 'CP866' TO s = exportFile;
EXPORT exportSku XML;
EXPORT exportSku OBJECTS st = store CSV ',' TO s = exportFile;
}