With this function you can export datasets into an XML spreadsheet.
Syntax
function ibec_ds_Export(Dataset : variant; ExportType : integer;
FileName : string; Options : string) : integer;
The ibec_ds_Export function exports datasets created with SELECT ... AS DATASET statement into a number of various data formats.
ibec_ds_Export always returns 0.
Parameters
Argument | Description |
Dataset | A dataset created with SELECT ... AS DATASET statement. |
ExportType | Type of export. |
FileName | Name of result file. |
Options | Set of export options. |
Export types
__etXLS | Microsoft Excel; obsolete, use __etXMLSpreadSheet instead. |
__etTXT | Plain text. |
__etCSV | Comma-separated values. |
__etDIF | DIFF |
__etSYLK | SYLK |
__etHTML | HTML |
__etXML | XML |
__etDBF | DBF |
__etXMLSpreadSheet | XML spreadsheet. |
__etJSON | JSON |
Options
CurrencyFormat | Format string for currency fields. |
DateFormat | Format string for date fields. |
DateTimeFormat | Format string for datetime fields. |
TimeFormat | Format string for time fields. |
FloatFormat | Format string for float/double precision fields. |
IntegerFormat | Format string for integer fields. |
ExportTextBlobs | Memo fields (text blobs) will be exported as regular strings if specified, otherwise they will be omitted. |
XML options
Encoding | Encoding of xml data (encoding attribute in <?xml version=“1.0” encoding=“utf-8”?>). |
StringAsText | If specified string data will appear in XML file as is, otherwise it will be MIME-encoded. |
MemoAsText | If specified memo fields data will appear in XML file as is, otherwise it will be MIME-encoded. |
DateTimeAsText | If specified date/time fields data will appear in XML file as is, otherwise it will be MIME-encoded. |
ConvertToUTF8 | Converts field data from ANSI to UTF8 before writing to XML file. |
TXT/CSV/DIF/SYLK/JSON options
Readable | (JSON) Adds some extra spaces/CRLFs to make result file friendly readable. |
WriteBOM | (JSON/TXT/CSV) Writes UTF8 BOM into the beginning of result file. |
OmitCaptions | Field captions will not be included in the result file if specified. |
QuoteStrings | (CSV) String values will be quoted using double quote char ("). |
Delimiter | (CSV) Delimiter char (semicolon is used by default). |
HTML options
Encoding | Encoding of html data (charset attribute in <META content="text/html; charset=utf8" http-equiv="Content-Type">). |
ConvertToUTF8 | Converts field data from ANSI to UTF8 before writing to HTML file. |
XLS/XML spreadsheet options
OmitCaptions | Field captions will not be included in the result file if specified. |
ConvertToUTF8 | (XML SpreadSheet) Converts field data from ANSI to UTF8 before writing to result file. |
It is possible to export data into XLSX format if XLS or XLSX export type is specified. There is no difference between XLS and XLSX export types.
DBF options
ConvertToDOS | Data will be converted from ANSI to OEM encoding. |
LongStringsToMemo | Long strings (with length > 254 bytes) will be written as memos, otherwise they will be truncated to 254 bytes. |
DateTimeAsDate | If specified datetime values will be exported as an 8-bytes string in the format YYYYMMDD, otherwise they will be converted to string using DateTimeFormat format. |
Example 1
execute ibeblock
as
begin
ExportOptions = 'ConvertToUTF8;
DateTimeFormat="dd-mm-yyy hh:nn:ss";
DateFormat="dd-mm-yyyy";
TimeFormat="hh:nn:ss";
CurrencyFormat="$0.00";
IntegerFormat="0";
FloatFormat="0.0000";
ExportTextBlobs';
try
select * from rdb$relation_fields
order by rdb$relation_name, rdb$field_position
as dataset dsFields;
ibec_ds_Export(dsFields, __etXMLSpreadSheet, 'D:\rdb$relation_fields.xml', ExportOptions);
ibec_ShellExecute('open', 'D:\rdb$relation_fields.xml', '', '', 0);
finally
if (dsFields is not null) then
ibec_ds_Close(dsFields);
end;
end
Example 2
select * from "Customer"
export as json into 'D:\MyData\customer.json'
options 'DateTimeFormat="dd-mm-yyy hh:nn:ss";
DateFormat="dd-mm-yyyy";
TimeFormat="hh:nn:ss";
ExportTextBlobs;
Readable;
WriteBOM';
Example 3
ExportOptions = 'DateTimeFormat="dd-mm-yyy hh:nn:ss";
DateFormat="dd-mm-yyyy";
TimeFormat="hh:nn:ss";
ExportTextBlobs;
Readable;
WriteBOM';
select * from "Customer" order by "CustNo" as dataset MyDS;
ibec_ds_Export(MyDS, __etJSON, 'D:\MyData\customer.json', ExportOptions);
ibec_ds_Close(MyDS);
See also:
SELECT ... EXPORT AS ... INTO
Export CSV data - another example
back to top of page
<< ibec_ds_Bof | IBEBlock | ibec_ds_FieldCount >>