Exporting
- 3 minutes to read
The GridControl provides a fast and flexible way to export its data to a file or stream in various formats. This topic consists of the following sections:
Overview
A View provides multiple methods to export its contents.
Method | Description |
---|---|
DataViewBase.ExportToHtml | Exports a grid to the specified file path in HTML format. |
DataViewBase.ExportToImage | Exports a grid to the specified file path in image format. |
DataViewBase.ExportToMht | Exports a grid to the specified file path in MHT format |
DataViewBase.ExportToPdf | Exports a grid to the specified file path in PDF format. |
DataViewBase.ExportToRtf | Exports a grid to the specified stream in RTF format. |
DataViewBase.ExportToText | Exports a grid to the specified stream in text format. |
DataViewBase.ExportToXps | Exports a grid to the specified file path in XPS format. |
TableView.ExportToCsv, TreeListView.ExportToCsv, CardView.ExportToCsv | Exports a grid to the specified stream in CSV format. |
TableView.ExportToXls, TreeListView.ExportToXls, CardView.ExportToXls | Exports a grid to the specified file path in XLS format. |
TableView.ExportToXlsx, TreeListView.ExportToXlsx, CardView.ExportToXlsx | Exports a grid to the specified stream in XLSX format. |
The Print Preview window allows you to customize the printed document, print or export it to a file in the required format. The image below illustrates the Print Preview window for a sample grid.
See the Printing Options section of the Printing topic to learn how to specify the View elements to be printed.
Export to XLS, XLSX, and CSV Formats
The GridControl supports two export modes when exporting data to XLS, XLSX, and CSV formats:
Data-aware Export
This is the default export mode, optimized for subsequent analysis of grid data within Microsoft Excel. Output documents retain various data shaping options that are applied within the grid. The data-aware export functionality provides improved performance and memory usage.
Note
Currently CardView does not support the data-aware export.
The GridControl supports the following features for all Excel export operations:
- Data Grouping - allows end-users to collapse/expand groups within a worksheet.
- Data Sorting and Filtering - allows end-users to display relevant data in the desired order.
- Totals and Group Summaries - allows end-users to modify/change formulas.
- Excel Style Conditional Formatting.
- Data Validation for lookup and combobox columns.
- Fixed Columns.
- Band Columns.
The data-aware export has the following limitations:
- Only master rows are shown when exporting master-detail data.
- Printing styles and templates are not supported.
- Custom summary export is not supported.
- Icon Sets that are used for conditional formatting are not supported.
WYSIWYG Export
In this export mode, resulting documents retain the layout of grid cells. Specific data shaping options are not retained, in comparison to the data-aware export.
Set the ExportSettings.DefaultExportType property to ExportType.WYSIWYG to enable the WYSIWYG export mode in an application.
The following code illustrates the WYSIWYG export to XLSX:
TableView.ExportToXlsx([Path], new XlsxExportOptionsEx { ExportType = ExportType.WYSIWYG })