Skip to main content
Tab

ASPxGridViewExporter Class

A component that allows you to export the ASPxGridView control’s data.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

public class ASPxGridViewExporter :
    ASPxGridExporterBase

Remarks

Tip

We recommend that you use the built-in export functionality.

The ASPxGridViewExporter component allows you to export ASPxGridView data to a file or stream in PDF, RTF, CSV, DOCX, XLS, and XLSX formats.

To export grid data, assign the grid control’s ID to the GridViewID property and call an export method.

<dx:ASPxGridView ID="grid" runat="server" DataSourceID="CustomerReportsDataSource" />
<dx:ASPxGridViewExporter ID="ASPxGridViewExporter1" runat="server" GridViewID="grid" />
ASPxGridViewExporter1.WriteXlsxToResponse();

Export Methods

The ASPxGridViewExporter component implements the following export methods:

Format Export to a Stream Export to the Response in Binary Format
CSV WriteCsv WriteCsvToResponse
DOCX WriteDocx WriteDocxToResponse
PDF WritePdf WritePdfToResponse
RTF WriteRtf WriteRtfToResponse
XLS WriteXls WriteXlsToResponse
XLSX WriteXlsx WriteXlsxToResponse

Excel Data-Aware Export

The ASPxGridViewExporter component can export data in XLS and XLSX formats in data-aware mode. This mode maintains the following data shaping settings in the exported document:

  • Data grouping.
  • Data sorting and filtering.
  • Totals and group summaries.
  • Format conditions.
  • Data validation for combo-box columns.
  • Fixed columns.

You can export grid data in Excel data-aware mode in the following way:

using DevExpress.XtraPrinting;
using DevExpress.Export;
// ...
ASPxGridViewExporter1.WriteXlsxToResponse(new XlsxExportOptionsEx { ExportType = ExportType.DataAware });

Important Notes

  • The exporter creates an exported document on a server. When you export a large amount of data to a server with limited memory, the OutOfMemoryException exception can appear.
  • If you create a control dynamically, add the ASPxGridViewExporter component to a page and recreate the component on every round-trip to the server.
  • Don’t export the ASPxGridView‘s content during callbacks, because ASP.NET does not support sending binary content during a callback.

Limitations

Data-Aware Mode Limitations

Use the default WYSIWYG export mode to avoid the specified limitations. Note that data shaping settings are lost in this mode.

See Also