Export
- 3 minutes to read
The Bootstrap Grid View is shipped with the ASPxGridViewExporter component that allows you to export BootstrapGridView data to a file or stream it in various formats - PDF, RTF, CSV, XLS, and XLSX.
To export grid data, assign its ID to the ASPxGridViewExporter.GridViewID property and select the export method. For example, to export data to a file in the XLS format, use the ASPxGridExporterBase.WriteXlsToResponse method.
Use the ASPxGridViewDetailSettings.ExportMode property to specify detail rows for exporting. For instance, set this property to Expanded to export only master rows and expanded detail rows.
You can customize the appearance of exported grid elements using the ASPxGridViewExporter.Styles property.
Note
The ASPxGridViewExporter cannot export hidden data columns and the content of templates. The exception is the BootstrapGridView control within the GridViewTemplates.DetailRow template. ASPxGridViewExporter can identify the grid within this type of a template, and allows both master and detail data to be exported.
Note that templated elements are exported with their default representation. For instance, if you export a grid with templated cells, they are represented as default labels with text in the obtained file.
Excel Data Aware Export
When exporting data in both XLS and XLSX formats, the following grid data are maintained in the resulting excel document.
- Data grouping - with the capability to collapse/expand groups within a worksheet.
- Data sorting and filtering - allowing end-users to display relevant data in the desired order.
- Totals and group summaries - with the capability to modify/change formulas.
- Format conditions - with the capability to modify/change conditional formatting rules.
- Data validation for combo-box columns
- Fixed columns
To learn more, see the following article: Export Modes.
Export Limitations
- When exporting data to Excel formats, the ASPxGridViewExporter.Landscape and ASPxGridViewExporter.PaperKind properties are not in effect.
- When exporting data to Excel formats, rich text formatting is ignored in ASPxGridViewExporter.ReportHeader and ASPxGridViewExporter.ReportFooter property values.
Data Aware Mode Limitations
- The ASPxGridViewExporter.Styles property has no effect. Use either the GridViewColumn.ExportCellStyle at the column level or the XlsExportOptionsEx.CustomizeCell / XlsxExportOptionsEx.CustomizeCell event instead.
- The ASPxGridViewExporter.ReportHeader and ASPxGridViewExporter.ReportFooter properties are not in effect.
- The ASPxGridViewExporter.RenderBrick event does not fire. You can use the XlsExportOptionsEx.CustomizeCell or XlsxExportOptionsEx.CustomizeCell event instead.
- The master-detail grid export is not supported.
You can avoid the specified limitations by using the WYSIWYG (What You See Is What You Get) export mode. However in this mode, the table formatting, e.g., grouping, is lost.
gridExport.WriteXlsxToResponse(new XlsxExportOptionsEx { ExportType = ExportType.WYSIWYG });