Export to Tabular Formats
- 6 minutes to read
Export to tabular data formats (CSV, XLS, XLSX) uses a data engine specified by the ExportType enumeration. Default engine performs a Data-Aware export with improved performance and memory usage. The resultant file is optimized for subsequent analysis with Microsoft Excel.
Data-Aware Export
The following features are retained in the XLS and XLSX documents:
- Data Grouping - you can collapse/expand groups within a worksheet.
- Fixed Headers - column and row areas stay in sight.
- Cells Formatting - retains the number format.
- Display Text/Value export - you can select whether to export display text or values.
Methods
Methods that perform the data-aware export are listed in the following table.
Method | Parameter |
---|---|
ASPxPivotGridExporter.ExportToCsv or ASPxPivotGridExporter.ExportCsvToResponse | Use the CsvExportOptionsEx instance instead of the CsvExportOptions object specified in the method signature. The CsvExportOptionsEx.ExportType property should be set to the ExportType.DataAware value (default). |
ASPxPivotGridExporter.ExportToXls or ASPxPivotGridExporter.ExportXlsToResponse | Use the PivotXlsExportOptions instance instead of the XlsExportOptions object specified in the method signature. The PivotXlsExportOptions.ExportType (inherited XlsExportOptionsEx.ExportType) property should be set to the ExportType.DataAware value (default). |
ASPxPivotGridExporter.ExportToXlsx or ASPxPivotGridExporter.ExportXlsxToResponse | Use the PivotXlsxExportOptions instance instead of the XlsxExportOptions object specified in the method signature. The PivotXlsxExportOptions.ExportType (inherited XlsxExportOptionsEx.ExportType) property should be set to the ExportType.DataAware value (default). |
Options
The PivotXlsExportOptions and PivotXlsxExportOptions classes inherits many properties from the XlsExportOptionsEx and XlsxExportOptionsEx classes, respectively. The data-aware export engine uses only a subset of available properties. To clarify the situation, the table below lists the properties which are in effect in the Data Aware mode.
Property | Description |
---|---|
Gets or sets a name of the sheet in the created XLS file to which a document is exported. | |
Gets or sets whether the row area in a Pivot Grid control becomes a frozen pane in the spreadsheet. | |
Gets or sets whether the column area becomes a frozen pane in the spreadsheet. | |
Gets or sets whether the data in the spreadsheet are grouped as they are displayed in the Pivot Grid control. | |
Gets or sets whether a title is displayed for each printed page of the exported document. | |
Gets or sets whether to include the column field headers in the XLS exported document. | |
Gets or sets whether to include the data field headers in the XLS exported document. | |
Gets or sets whether to include the filter field headers in the XLS exported document. | |
Gets or sets whether to include the row field headers in the XLS exported document. | |
Gets or sets the export mode. You can switch between WYSIWYG and data-aware export type. | |
Gets or sets whether groups are collapsed or expanded in the exported document. | |
Enables the mode that produces simple tabular data without graphic elements, style and appearance settings. | |
Specifies whether data are exported as strings or values. |
Runtime Customization
To customize exported pivot grid elements individually, handle the following events:
Event | Description |
---|---|
PivotXlsExportOptions.CustomizeCell | Allows you to specify cell formatting when exporting a Pivot Grid control to XLSX format in data-aware mode. |
XlsExportOptionsEx.AfterAddRow | Fires immediately after a row is added to the output document.Only available in data-aware export mode. |
XlsExportOptionsEx.BeforeExportTable | Allows you to customize a native Excel table’s settings before export. This event is in effect when the XlsExportOptionsEx.LayoutMode property is set to Table.Only available in data-aware export mode. |
XlsExportOptionsEx.CustomizeDocumentColumn | Allows you to customize an individual column in the exported document - change its width, formatting, collapse the group containing the column or hide the column. |
XlsExportOptionsEx.CustomizeSheetFooter | Allows you to add a footer to the output document. Only available in data-aware export mode. |
XlsExportOptionsEx.CustomizeSheetHeader | Allows you to add a header to the output document.Only available in data-aware export mode. |
XlsExportOptionsEx.CustomizeSheetSettings | Allows you to customize the output document’s settings. Only available in data-aware export mode. |
XlsExportOptionsEx.DocumentColumnFiltering | Allows you to apply filters to the exported document’s columns.Only available in data-aware export mode. |
XlsExportOptionsEx.SkipFooterRow | Allows you to hide certain summary footers (or certain multi-line summary footers’ lines) from the exported document.Only available in data-aware export mode. |
WYSIWYG Export
The WYSIWYG export mode employs the XtraPrinting library engine. It reproduces the layout of control elements in XLS and XLSX formats, omitting data shaping characteristics available in the DataAware export mode. In CSV format, WYSIWYG mode may export column headers and empty columns for accurate visual representation.
Methods that perform the export in WYSIWYG mode are listed in the following table.
Method | Parameter |
---|---|
ASPxPivotGridExporter.ExportToCsv or ASPxPivotGridExporter.ExportCsvToResponse | Use the CsvExportOptionsEx instance instead of the CsvExportOptions object specified in the method signature. The CsvExportOptionsEx.ExportType property should be set to the ExportType.WYSIWYG value. |
ASPxPivotGridExporter.ExportToXls or ASPxPivotGridExporter.ExportXlsToResponse | Use the PivotXlsExportOptions instance instead of the XlsExportOptions object specified in the method signature. The PivotXlsExportOptions.ExportType (inherited XlsExportOptionsEx.ExportType) property should be set to the ExportType.WYSIWYG value. |
ASPxPivotGridExporter.ExportToXlsx or ASPxPivotGridExporter.ExportXlsxToResponse | Use the PivotXlsxExportOptions instance instead of the XlsxExportOptions object specified in the method signature. The PivotXlsxExportOptions.ExportType (inherited XlsxExportOptionsEx.ExportType) property should be set to the ExportType.WYSIWYG value. |
Options
The PivotXlsExportOptions and PivotXlsxExportOptions classes inherits many properties from the XlsExportOptionsEx and XlsxExportOptionsEx classes, respectively. The WYSIWYG mode (the Printing Library export engine) uses only a subset of available properties. The table below lists the properties which are in effect in the WYSIWYG mode.
Property | Description |
---|---|
XlExportOptionsBase.DocumentOptions | Provides access to options to be embedded as the resulting XLS or XLSX file’s Document Properties. |
XlExportOptionsBase.EncryptionOptions | Provides access to the XLS and XLSX file encryption options. |
XlsExportOptions.ExportMode | Specifies whether the document should be exported to a single or different XLS files, each page in a separate file. |
XlsExportOptionsEx.ExportType | Gets or sets the export type - WYSIWYG or Data Aware. |
XlExportOptionsBase.IgnoreErrors | Specifies the document errors to be ignored in a resulting Excel file. |
XlExportOptionsBase.RawDataMode | Enables the mode that produces simple tabular data without graphic elements, style and appearance settings. |
XlExportOptionsBase.RightToLeftDocument | Gets or sets whether the layout of the resulting XLS document should be aligned to support locales using right-to-left fonts. |
XlExportOptionsBase.SheetName | Gets or sets a name of the sheet in the created XLS file to which a document is exported. |
XlExportOptionsBase.ShowGridLines | Gets or sets whether worksheet gridlines are visible in the resulting XLS file. |
XlsExportOptions.Suppress256ColumnsWarning | Gets or sets a value indicating whether to suppress the exception that raises when trying to export a document to an XLS file with more than 256 columns. |
XlsExportOptions.Suppress65536RowsWarning | Gets or sets a value indicating whether to suppress the exception that raises when trying to export a document to an XLS file with more than 65,536 rows. |
XlExportOptionsBase.TextExportMode | Gets or sets a value indicating whether the cells in the resulting XLS document should use the same formatting as the original document. |