Blazor Grid — Export Data to Excel (v22.2)

ASP.NET Team Blog
17 January 2023

In this short post, I’ll briefly describe our new Excel data export option (v22.2). As you’ll see below, exported (XLS and XLSX) documents retain data shaping options applied within our Blazor Data Grid prior to the export operation (data grouping, sorting, totals and group summaries).

Data Groups

When using our Blazor Grid’s new export option, your exported document will retain information about applied data groups. And yes, users can expand and collapse groups within the exported worksheet.

You can specify whether to export each group row in an expanded/collapsed state, or prevent group row export (GroupExportMode).

Data Sorting

Our new Excel export option will maintain applied sort order within the exported document.

Totals and Group Summaries

Totals and group summaries within our Blazor Grid will be exported as calculated formulas.

You can prevent the DevExpress Blazor Grid from exporting group summaries (ExportGroupSummaries) or total summaries (ExportTotalSummaries) as needs dictate.

Export Methods

Our Blazor Grid exposes the following Excel-related data export methods:

You can choose to write the generated document to a stream or to a file (downloaded to the client machine).

<DxGrid @ref="Grid" Data="Data" >
    @* ... *@
<DxButton Text="Export Grid Data to XLSX" Click="ExportXlsx_Click" />
@code {
    IEnumerable<object> Data { get; set; }
    IGrid Grid { get; set; }
    protected override async Task OnInitializedAsync() {
        Data = await NwindDataService.GetCustomersAsync();
    async Task ExportXlsx_Click() {
        await Grid.ExportToXlsxAsync("ExportResult", new GridXlExportOptions() { });

Export methods accept the options parameter. This parameter allows you to customize a variety of settings in the generated document. For instance, you can write handlers for the following actions:

  • RowExporting action: allows you to filter exported grid data.
  • CustomizeSheet action: allows you to customize settings for the generated document.
  • CustomizeCell action: allows you to substitute a cell value, insert a hyperlink in the cell, or customize the cell’s format.

To explore the capabilities of our export option in greater detail, feel free to review the following online demo: Export Data.

Your Feedback Counts

As always, we appreciate your feedback.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.