Custom Export

  • 3 minutes to read
TIP

Starting with version 17.2, we recommend using the client API, built-in toolbar and context menu commands for ASPxGridView data exporting.

The ASPxGridView allows using the ASPxGridViewExporter component to export the grid data to a file or stream in PDF, RTF, CSV, DOCX, XLS, and XLSX format in addition to the built-in exporting mechanism (using the standard toolbar commands, client-side and server-side API).

ASPxGridView-Export-Exporter

Assign ASPxGridView's ID to the ASPxGridViewExporter.GridViewID property and select the exporting method. For example, use the ASPxGridExporterBase.WriteXlsToResponse method to export data to a file in an XLS format. Refer to the Member Table: Custom Export topic to review a list of available export methods.

Use the ASPxGridViewDetailSettings.ExportMode property to specify which detail rows are exported. For example, set this property to Expanded to export only master rows and expanded detail rows.

The ASPxGridViewExporter.Styles property allows customizing the exported grid elements' appearance.

IMPORTANT
  • The ASPxGridViewExporter cannot export hidden data columns or templates' content. The ASPxGridViewExporter identifies grids within GridViewTemplates.DetailRow templates, and allows exporting both master and detail data. 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.
  • Add the ASPxGridViewExporter to the page's controls and recreate it on every round-trip to the server if it's created dynamically.

Excel Data Aware Export

The resulting excel document maintains the following grid data when exporting data in both XLS and XLSX formats:

  • Data grouping - allows collapsing/expanding groups within a worksheet.
  • Data sorting and filtering - allows end-users to display relevant data in a specific order.
  • Totals and group summaries - with the ability to modify/change formulas.
  • Format conditions - with the ability to modify/change conditional formatting rules.
  • Data validation for combo-box columns
  • Fixed columns

See the Knowledge Base Article: ASPxGridView / MVC GridView Extension - Excel Data Aware Export FAQ for more information.

Export Limitations

Data Aware Mode Limitations

You can avoid the specified limitations using the WYSIWYG (What You See Is What You Get) export mode. However, the table formatting (for example, grouping) is lost in this mode.

gridExport.WriteXlsxToResponse(new XlsxExportOptionsEx { ExportType = ExportType.WYSIWYG });

Member Table

Task-Based Help