VCL Data Grid: Data Export
- 5 minutes to read
The TcxGrid control ships with a series of global data export methods declared in the cxGridExportLink unit. You can call these methods to export grid content to a file or stream in CSV, HTML, TXT, XLS, XLSX, and XML formats. To track the export progress and perform additional actions before an export operation, you can pass a handler object as the optional AHandler
parameter available for every data export method. The handler object should implement the IcxExportProgress and IcxExportBeforeSave interfaces declared in the cxExport unit. Refer to the following topic for detailed information on handler objects and a code example: How to: Track Data Export Progress.
Plain Text-Based Formats
Plain text-based formats include CSV and TXT. Use these lean formats if you need to keep the exported data size to a minimum. Remember that plain text-based formats cannot preserve data layouts and appearance settings as customized by you or your users.
Comma-Separated Values (CSV)
In comma-separated values format, every plain text line of values separated by commas corresponds to a data record. You can pass another character as the optional ASeparator
parameter to use it instead of a comma.
- ExportGridToCSV
- Exports content of a data grid control to a file in CSV (comma-separated values) format.
- ExportGridToCSVStream
- Exports content of a data grid control to a stream in CSV (comma-separated values) format.
- ExportGridDataToCSV
- Exports cell content of a data grid to a CSV (comma-separated values) file.
- ExportGridDataToCSVStream
- Exports cell content of a data grid to a stream in CSV (comma-separated values) format.
Plain Text (TXT)
Like CSV, the plain text format stores exported data as plain text without formatting, style, or print layout information. Compared to CSV, exported TXT files are more human-readable. You can use the ASeparator
, ABeginString
, and AEndString
parameters of the export methods to delimit cell values in the resulting file or stream.
- ExportGridToText
- Exports content of a data grid control to a file in plain text format.
- ExportGridToTextStream
- Exports content of a data grid control to a stream in plain text format.
- ExportGridDataToText
- Exports cell content of a data grid to a file in plain text format.
- ExportGridDataToTextStream
- Exports cell content of a data grid to a stream in plain text format.
Markup Language Formats
Markup language formats include HTML and XML. Unlike plain text, these formats allow you to export the original data layout as is and take style and look & feel settings into account. Export methods in this category create image files to display cell images as inline images in the output file or stream. Use the cxExportGraphicClass global constant to change the image container class for export image generation.
HyperText Markup Language (HTML)
Export grid content in HyperText Markup Language format if you need to display data in a web browser.
- ExportGridToHTML
- Exports content of a data grid control to a file in HTML format.
- ExportGridToHTMLStream
- Exports content of a data grid control to a stream in HTML format.
- ExportGridDataToHTML
- Exports cell content of a data grid to a file in HTML format.
- ExportGridDataToHTMLStream
- Exports cell content of a data grid to a stream in HTML format.
Extensible Markup Language (XML)
- ExportGridToXML
- Exports content of a data grid control to a file in XML format.
- ExportGridToXMLStream
- Exports content of a data grid control to a stream in XML format.
- ExportGridDataToXML
- Exports cell content of a data grid to a file in XML format.
- ExportGridToXMLStream
- Exports content of a data grid control to a stream in XML format.
Spreadsheet Document Formats
Spreadsheet document formats include Office Open XML (XLSX) and Microsoft Excel® binary spreadsheet (XLS) formats. Like markup language formats, they allow you to export grid content as is, including the data layout, style, and look & feel settings.
Office Open XML Spreadsheet (XLSX and XLTX)
A compressed XML-based spreadsheet document format used by Microsoft Excel® 2007 and later versions.
- ExportGridToXLSX
- Exports the currently active root level’s content to a file in Office Open XML spreadsheet format (XLSX).
- ExportGridToXLSXStream
- Exports content of a data grid control to a stream in Office Open XML spreadsheet format (XLSX).
- ExportGridDataToXLSX
- Exports cell content of a data grid to a file in Office Open XML spreadsheet format (XLSX).
- ExportGridDataToXLSXStream
- Exports cell content of a data grid to a stream in Office Open XML spreadsheet format (XLSX).
Microsoft Excel® Binary Spreadsheet (XLS and XLT)
The spreadsheet document binary format used by Microsoft Excel® 97-2003.
- ExportGridToExcel
- Exports content of a data grid control to a file in Microsoft Excel® binary format (XLS).
- ExportGridToExcelStream
- Exports content of a data grid control to a stream in Microsoft Excel® binary Format (XLS).
- ExportGridDataToExcel
- Exports cell content of a data grid to a file in Microsoft Excel® binary format (XLS).
- ExportGridDataToExcelStream
- Exports cell content of a data grid to a stream in Microsoft Excel® binary format (XLS).
Note
Make sure you added the cxGridExportLink and cxExport units to your project’s uses clause to be able to call these data export methods.