Description:
Convert a sequence into a string.
Syntax:
A.export(x:F,…;s)
Note:
The function separates each selected fields x of records in table sequence/record sequence/sequence A with the user-defined separator and returns the result as a string. The name of the resulting field in the string is F. If x isn’t specified, then export all fields. Return a one-field string without a field name if A is a simple sequence; use separator when A's members are sequences. A serial byte value is stored as an integer.
If parameters x:F are absent and if A is a sequence of record, then these records should be of same structure.
The function returns JSON strings when members of each member of A is record, sequence or table sequence; and returns a hexadecimal string when records or members of A are serial byte keys.
Note: In the returned string, use line break to separate records and custom delimiter to separate fields. By default, use TAB to separate both.
Parameter:
A |
A table sequence/record sequence/sequence to be exported |
x |
Fields to be exported; if omitted, then export all fields of A |
F |
Name of the resulting field in the string; if omitted, then use the original field name |
s |
User-defined field separator; default is TAB |
Option:
@t |
The column names will be written to the string as the first record |
@c |
Use comma as the separator when parameter s is absent |
@w |
Use Windows-style \r\n line break; by default, the line break is specified by the operating system |
@q |
Enclose the exported text field values and headers with quotation marks |
@o |
Perform escaping according to the Excel rule, which treats two double quotation marks as one and does not escape the other characters; need to work with @q |
Return value:
String
Example:
|
A |
|
1 |
=demo.query("select EID,NAME from EMPLOYEE") |
|
2 |
=A1.export() |
Parameters x, F, and s are omitted. |
3 |
=A1.export(;"|") |
Specify the separator as "|". |
4 |
=A1.export@t(EID:id,NAME:name;",") |
Specify to-be-exported fields and the separator; make column names the first record and write it at the beginning of the exported string. |
5 |
[1,23,34,45] |
A sequence. |
6 |
=A5.export() |
|
7 |
=A1.export@c() |
With @c option, use default separator comma when parameter s is absent. |
8 |
=A1.export@w() |
|
9 |
=["12\r34","aa\nbb"] |
|
10 |
=A9.export() |
|
11 |
=A9.export@q() |
With @q option, the exported content contains quotation marks. |
12 |
<xml><row><DEPTID>1</DEPTID><DEPTNAME>sale</DEPTNAME> <FATHER>12</FATHER></row><row><DEPTID>10</DEPTID> <DEPTNAME>create</DEPTNAME><FATHER>12</FATHER></row></xml> |
|
13 |
=xml(A12) |
Return a sequence of table sequences:
Expand members of the sequence as follows:
Then expand sub-members of the sequence as follows:
|
14 |
=A13.export() |
Return JSON strings.
|
15 |
=file("D://t4.txt").import@coq() |
Below is content of t4.txt:
A15’s result:
|
16 |
=A15.export@coq() |
With @o option, two double quotation marks are treated as one.
|
Related function: