aspnet-116329-components-vertical-grid-concepts-export.md
The ASPxVerticalGrid control allows you to export data to a file or stream in PDF, RTF, CSV, XLS, XLSX, and DOCX formats. To allow users to export data in your application, you can either rely on the grid’s built-in UI or use the client and server APIs in code.
Run Demo: Vertical Grid - Exporting to Different Formats
The export commands and the client API are disabled for security reasons (the default setting). To enable this functionality, set the EnableClientSideExportAPI property to true.
Important
DevExpress controls require the DevExpress.RichEdit.v25.2.Export.dll library to export their content to DOCX or RTF format.
The ASPxVerticalGrid toolbar implements the following commands to export grid data: ExportToCsv, ExportToPdf, ExportToRtf, ExportToDocx, ExportToXls, and ExportToXlsx.
Populate a grid toolbar with a VerticalGridToolbarItem object and set its Command property to an export command to add the corresponding item to the toolbar.
Run Demo: Toolbar Read Tutorial: ASPxVerticalGrid toolbars
<dx:ASPxVerticalGrid ID="VerticalGrid" runat="server" KeyFieldName="ProductID" DataSourceID="ProductsDataSource" Width="100%">
<Toolbars>
<dx:VerticalGridToolbar EnableAdaptivity="true">
<Items>
<dx:VerticalGridToolbarItem Command="ExportToXls" />
<dx:VerticalGridToolbarItem Command="ExportToXlsx" />
<dx:VerticalGridToolbarItem Command="ExportToCsv" />
</Items>
</dx:VerticalGridToolbar>
</Toolbars>
<!-- ... -->
</dx:ASPxVerticalGrid>
Call the client ExportTo(format) method to export grid data to a file in the specified format.
<dx:ASPxVerticalGrid ClientInstanceName="verticalGrid" ID="ASPxVerticalGrid1" runat="server" Width="700px" AutoGenerateRows="False" DataSourceID="SqlDataSource3" KeyFieldName="ProductID">
<SettingsExport EnableClientSideExportAPI="true" />
<Rows>
...
</Rows>
</dx:ASPxVerticalGrid>
<dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="Export">
<ClientSideEvents Click="function(s, e) {
verticalGrid.ExportTo(ASPxClientVerticalGridExportFormat.Xls);
}" />
</dx:ASPxButton>
The ASPxVerticalGrid component implements the following export methods:
| Format | Export to a Stream | Export to the Response |
|---|---|---|
| CSV | ExportToCsv | ExportCsvToResponse |
| DOCX | ExportToDocx | ExportDocxToResponse |
| ExportToPdf | ExportPdfToResponse | |
| RTF | ExportToRtf | ExportRtfToResponse |
| XLS | ExportToXls | ExportXlsToResponse |
| XLSX | ExportToXlsx | ExportXlsxToResponse |
switch(e.Item.Name) {
case "CustomExportToXLS":
verticalGrid.ExportXlsToResponse(new DevExpress.XtraPrinting.XlsExportOptionsEx { ExportType = ExportType.WYSIWYG });
break;
case "CustomExportToXLSX":
verticalGrid.ExportXlsxToResponse(new DevExpress.XtraPrinting.XlsxExportOptionsEx { ExportType = ExportType.WYSIWYG });
break;
default:
break;
}
You can use the StylesExport property to customize the exported ASPxVerticalGrid elements’ appearance.