Back to Devexpress

Export to Tabular Formats

aspnet-114651-components-pivot-grid-export-export-to-tabular-formats.md

latest15.5 KB
Original Source

Export to Tabular Formats

  • Dec 17, 2020
  • 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

| | --- | --- | |

XlExportOptionsBase.SheetName

|

Gets or sets a name of the sheet in the created XLS file to which a document is exported.

| |

XlsExportOptionsEx.AllowFixedColumns

XlsxExportOptionsEx.AllowFixedColumns

|

Gets or sets whether the row area in a Pivot Grid control becomes a frozen pane in the spreadsheet.

| |

XlsExportOptionsEx.AllowFixedColumnHeaderPanel

XlsxExportOptionsEx.AllowFixedColumnHeaderPanel

|

Gets or sets whether the column area becomes a frozen pane in the spreadsheet.

| |

XlsExportOptionsEx.AllowGrouping

XlsxExportOptionsEx.AllowGrouping

|

Gets or sets whether the data in the spreadsheet are grouped as they are displayed in the Pivot Grid control.

| |

XlsExportOptionsEx.ShowPageTitle

XlsxExportOptionsEx.ShowPageTitle

|

Gets or sets whether a title is displayed for each printed page of the exported document.

| |

PivotXlsExportOptionsBase.ExportColumnAreaHeaders

|

Gets or sets whether to include the column field headers in the XLS exported document.

| |

PivotXlsExportOptionsBase.ExportDataAreaHeaders

|

Gets or sets whether to include the data field headers in the XLS exported document.

| |

PivotXlsExportOptionsBase.ExportFilterAreaHeaders

|

Gets or sets whether to include the filter field headers in the XLS exported document.

| |

PivotXlsExportOptionsBase.ExportRowAreaHeaders

|

Gets or sets whether to include the row field headers in the XLS exported document.

| |

XlsExportOptionsEx.ExportType

XlsxExportOptionsEx.ExportType

|

Gets or sets the export mode. You can switch between WYSIWYG and data-aware export type.

| |

XlsExportOptionsEx.GroupState

XlsxExportOptionsEx.GroupState

|

Gets or sets whether groups are collapsed or expanded in the exported document.

| |

XlExportOptionsBase.RawDataMode

|

Enables the mode that produces simple tabular data without graphic elements, style and appearance settings.

| |

XlExportOptionsBase.TextExportMode

|

Specifies whether data are exported as strings or values.

|

Runtime Customization

To customize exported pivot grid elements individually, handle the following events:

EventDescription
PivotXlsExportOptions.CustomizeCellAllows you to specify cell formatting when exporting a Pivot Grid control to XLSX format in data-aware mode.
XlsExportOptionsEx.AfterAddRowFires immediately after a row is added to the output document.Only available in data-aware export mode.
XlsExportOptionsEx.BeforeExportTableAllows 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.CustomizeDocumentColumnAllows 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.CustomizeSheetFooterAllows you to add a footer to the output document. Only available in data-aware export mode.
XlsExportOptionsEx.CustomizeSheetHeaderAllows you to add a header to the output document.Only available in data-aware export mode.
XlsExportOptionsEx.CustomizeSheetSettingsAllows you to customize the output document’s settings. Only available in data-aware export mode.
XlsExportOptionsEx.DocumentColumnFilteringAllows you to apply filters to the exported document’s columns.Only available in data-aware export mode.
XlsExportOptionsEx.SkipFooterRowAllows 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.

PropertyDescription
XlExportOptionsBase.DocumentOptionsProvides access to options to be embedded as the resulting XLS or XLSX file’s Document Properties.
XlExportOptionsBase.EncryptionOptionsProvides access to the XLS and XLSX file encryption options.
XlsExportOptions.ExportModeSpecifies whether the document should be exported to a single or different XLS files, each page in a separate file.
XlsExportOptionsEx.ExportTypeGets or sets the export type - WYSIWYG or Data Aware.
XlExportOptionsBase.IgnoreErrorsSpecifies the document errors to be ignored in a resulting Excel file.
XlExportOptionsBase.RawDataModeEnables the mode that produces simple tabular data without graphic elements, style and appearance settings.
XlExportOptionsBase.RightToLeftDocumentGets or sets whether the layout of the resulting XLS document should be aligned to support locales using right-to-left fonts.
XlExportOptionsBase.SheetNameGets or sets a name of the sheet in the created XLS file to which a document is exported.
XlExportOptionsBase.ShowGridLinesGets or sets whether worksheet gridlines are visible in the resulting XLS file.
XlsExportOptions.Suppress256ColumnsWarningGets 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.Suppress65536RowsWarningGets 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.TextExportModeGets or sets a value indicating whether the cells in the resulting XLS document should use the same formatting as the original document.

See Also

Pivot Grid Export