Skip to main content
A newer version of this page is available. .

Export

  • 3 minutes to read

Note

The information in this topic applies to DevExpress ASP.NET Vertical Grid version 17.2 and later.

The ASPxVerticalGrid allows exporting its data to a file or stream in various formats - PDF, RTF, CSV, XLS, XLSX, and DOCX.

VerticalGrid_Export

Note

Exporting using built-in toolbar commands and client-side API is disabled by default due to possible security issues. To enable such grid exporting functionality, set the ASPxGridExportSettings.EnableClientSideExportAPI property to true.

ASPxVerticalGrid data exporting can be implemented using one of the following:

  • Standard toolbar commands

    The ASPxVerticalGrid toolbar provides the most important or frequently used grid command including export commands. Using the VerticalGridToolbarItem.Command property setting, trigger one of the standard grid commands for exporting (listed below). For more information on using grid toolbars, refer to the ASPxVerticalGrid toolbars topic or the Toolbar online demo.

    <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>
        <Columns>
        ...
        </Columns>
    </dx:ASPxVerticalGrid>
    
  • Exporting API

    Perform an appropriate server or client method to implement grid data exporting. For a list of available methods, see Member Table: Export.

    The following examples illustrates how to use client and server exporting methods:

    • Client API

      <dx:ASPxVerticalGrid ClientInstanceName="verticalGrid" ID="ASPxVerticalGrid1" runat="server" Width="700px" AutoGenerateRows="False" DataSourceID="SqlDataSource3" KeyFieldName="ProductID">
      <SettingsExport EnableClientSideExportAPI="true" />
          <Rows>
          ...
          </Rows>
      </dx:ASPxVerticalGrid>
      <br />
      <dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="Export">
          <ClientSideEvents Click="function(s, e) {
              verticalGrid.ExportTo(ASPxClientVerticalGridExportFormat.Xls);
          }" />
      </dx:ASPxButton>
      
    • Server API

      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 customize the exported ASPxVerticalGrid elements’ appearance with the ASPxVerticalGrid.StylesExport property.

Note

The ASPxVerticalGrid cannot export data records that are hidden or export templates’ content.

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 is maintained in the resulting excel document:

  • Data sorting and filtering - allowing end-users to display relevant data in the desired 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

Excel Format (XLS or XLSX) Export Limitations

Exporting a vertical grid to an Excel format (XLS or XLSX) has the following limitations.

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

ASPxVerticalGrid1.ExportXlsxToResponse(new XlsxExportOptionsEx { ExportType = ExportType.WYSIWYG });

Online Demo

To see the data export in action, please refer to the Exporting to Different Formats online demo.

Member Table