Skip to main content
Version: 7.0

Brief: data export

Data export map

A detailed map of a single area — exporting data from the system to a file. The overall element map is in Brief, the full syntax is in the EXPORT operator, and the mechanism is described in Data export.

This article is not part of the set always passed to the assistant; it is requested when needed.

Two export sources

Exporting properties

EXPORT [format] FROM [columnId =] expr, ... [WHERE expr] [ORDER expr [DESC], ...] [TOP expr] [OFFSET expr] [TO propertyId]

Each listed expression becomes a column of the result. The result is always flat — a single table of rows.

Exporting a form

EXPORT formName [OBJECTS objName = expr, ...] [format] [TOP ...] [OFFSET ...] [TO ...]

The form is opened in the structured view, so its object group hierarchy is carried into the result for JSON and XML. For the flat formats (CSV, XLS, XLSX, DBF, TABLE) each object group is exported to a separate file. Objects whose values are fixed in the OBJECTS block act as filters and do not participate in building the group hierarchy.

Formats and extensions

If no format is specified, JSON is used. The extension of the resulting file is determined by the format when the value class of the destination property is FILE.

FormatExtension
JSONjson
XMLxml
CSVcsv
XLSxls
XLSXxlsx
DBFdbf
TABLEtable

Format options and their defaults

FormatOptionsDefaults
JSONCHARSETUTF-8
XMLHEADER / NOHEADER, ROOT, TAG, ATTR, CHARSETHEADER, UTF-8; values in child tags
CSVseparator, HEADER / NOHEADER, ESCAPE / NOESCAPE, CHARSET;, NOHEADER, ESCAPE, UTF-8
XLS, XLSXSHEET, HEADER / NOHEADERNOHEADER
DBFCHARSETCP1251
TABLEnone

For XML, HEADER controls not a table header row but a line such as <?xml version="1.0" encoding="UTF-8"?>. The name of the root element is set by ROOT (by default the name of the exported form, or export when properties are exported), and the name of the element wrapping each record by TAG (by default the name of the form's object group).

Result destination

  • TO propertyId — a property without parameters whose value class is a file class (FILE, RAWFILE, JSONFILE and so on).
  • If TO is not specified, the System.exportFile property is used.
  • When a form is exported to a flat format, the destination is set per object group: TO (groupId1 = propertyId1, ...); the empty object group is named root.

Defaults that shape the result

  • The format is JSON.
  • WHERE is the disjunction of all exported properties, so the exported sets of objects are those for which at least one of them is not NULL.
  • Column names are expr1, ..., exprN by the position of the expression in the list.
  • ORDER allows only expressions listed among the exported ones.
  • When a single value is exported without a column name, the JSON result contains the value itself rather than an object with a field.

Examples

exportSkus (Store store) {
EXPORT DBF CHARSET 'CP866' FROM id(Sku s), name(s), weight(s) WHERE in(store, s);
EXPORT CSV NOHEADER NOESCAPE FROM id(Sku s), name(s), weight(s) WHERE in(store, s);
EXPORT FROM id(Sku s), name(s), weight(s) WHERE in(store, s) ORDER name(s) DESC;
}
exportSku (Store store) {
EXPORT exportSku OBJECTS st = store DBF CHARSET 'CP866';
EXPORT exportSku XML;
}