Back to Devexpress

ASPxGridViewExporter Class

aspnet-devexpress-dot-web-be352c28.md

latest8.1 KB
Original Source

ASPxGridViewExporter Class

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

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public class ASPxGridViewExporter :
    ASPxGridExporterBase
vb
Public Class ASPxGridViewExporter
    Inherits 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.

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

Export Methods

The ASPxGridViewExporter component implements the following export methods:

FormatExport to a StreamExport to the Response in Binary Format
CSVWriteCsvWriteCsvToResponse
DOCXWriteDocxWriteDocxToResponse
PDFWritePdfWritePdfToResponse
RTFWriteRtfWriteRtfToResponse
XLSWriteXlsWriteXlsToResponse
XLSXWriteXlsxWriteXlsxToResponse

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:

csharp
using DevExpress.XtraPrinting;
using DevExpress.Export;
// ...
ASPxGridViewExporter1.WriteXlsxToResponse(new XlsxExportOptionsEx { ExportType = ExportType.DataAware });
vb
Imports DevExpress.XtraPrinting
Imports DevExpress.Export
' ...
ASPxGridViewExporter1.WriteXlsxToResponse(New XlsxExportOptionsEx With {.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.

Implements

IComponent

IDisposable

IParserAccessor

IUrlResolutionService

IDataBindingsAccessor

IControlBuilderAccessor

IControlDesignerAccessor

IExpressionsAccessor

IBasePrintable

Inheritance

Object Control ASPxGridExporterBase ASPxGridViewExporter MVCxGridViewExporter

See Also

ASPxGridViewExporter Members

Grid View

Export Grid View Data

DevExpress.Web Namespace