· 8 min read

How to Export a Blazor DataGrid to Excel (XLSX) — No Dependencies

Step-by-step guide to exporting Blazor DataGrid data to Excel XLSX files. Zero external dependencies, one-line API, supports styled headers and filters.

blazorexcelexportxlsxdatagridcsvc#

How to Export a Blazor DataGrid to Excel (XLSX)

Exporting grid data to Excel is one of the most requested features in enterprise Blazor apps. Most solutions require third-party NuGet packages like EPPlus or ClosedXML, adding licensing complexity and bundle size. Arcadia DataGrid includes built-in Excel export with zero extra dependencies.

The Problem with DIY Excel Export

The typical approach for Blazor Excel export involves:

  1. Adding a package like EPPlus ($299/year commercial license) or ClosedXML
  2. Writing manual serialization code for each data type
  3. Handling column formatting, headers, and filters separately
  4. Managing memory for large datasets
  5. Triggering a file download via JS interop

That’s a lot of plumbing for something that should be one line of code.

Quick Start

dotnet add package Arcadia.DataGrid
dotnet add package Arcadia.Theme

Add CSS to your App.razor:

<link href="_content/Arcadia.Theme/css/arcadia.css" rel="stylesheet" />
<link href="_content/Arcadia.DataGrid/css/arcadia-datagrid.css" rel="stylesheet" />

One-Line Excel Export

@using Arcadia.DataGrid.Components

<ArcadiaDataGrid @ref="grid" TItem="Invoice" Items="@invoices"
                 Sortable="true" Filterable="true">
    <ArcadiaGridColumn Field="@nameof(Invoice.Number)" Header="Invoice #" />
    <ArcadiaGridColumn Field="@nameof(Invoice.Customer)" Header="Customer" />
    <ArcadiaGridColumn Field="@nameof(Invoice.Amount)" Header="Amount" Format="C2" />
    <ArcadiaGridColumn Field="@nameof(Invoice.DueDate)" Header="Due Date" Format="d" />
    <ArcadiaGridColumn Field="@nameof(Invoice.Status)" Header="Status" />
</ArcadiaDataGrid>

<button class="arcadia-btn arcadia-btn-primary" @onclick="ExportExcel">
    Export to Excel
</button>

@code {
    private ArcadiaDataGrid<Invoice> grid = default!;
    private List<Invoice> invoices = new();

    protected override async Task OnInitializedAsync()
    {
        invoices = await InvoiceService.GetAllAsync();
    }

    private async Task ExportExcel()
    {
        await grid.ExportToExcelAsync();
    }
}

That’s it. The grid exports all visible columns with their current sort/filter state, formatted headers, and proper Excel data types.

Customizing the Export

Control which columns export, the file name, and whether to include only filtered rows:

@code {
    private async Task ExportFiltered()
    {
        await grid.ExportToExcelAsync(new ExcelExportOptions
        {
            FileName = "invoices-march-2026",
            IncludeHeaders = true,
            ExportFilteredOnly = true,
            SheetName = "Invoices",
            Columns = new[] { "Number", "Customer", "Amount", "Status" }
        });
    }
}

CSV Export

Prefer CSV? Same one-line API:

<button @onclick="() => grid.ExportToCsvAsync()">Export CSV</button>

Or with options:

@code {
    private async Task ExportCsv()
    {
        await grid.ExportToCsvAsync(new CsvExportOptions
        {
            FileName = "invoices-export",
            Delimiter = ",",
            IncludeHeaders = true,
            ExportFilteredOnly = true
        });
    }
}

Excel vs CSV — When to Use Which

Excel (XLSX)CSV
FormattingStyled headers, column widths, data typesPlain text
File sizeCompressed (smaller for large data)Larger for big datasets
CompatibilityExcel, Google Sheets, LibreOfficeUniversal
Multiple sheetsYesNo
Best forEnd users, reports, sharingData pipelines, imports

How It Compares

ArcadiaEPPlusClosedXMLMudBlazorSyncfusion
Built-in to gridYesNo (separate)No (separate)NoYes
Extra NuGetNoneRequiredRequiredRequiredNone
License cost$299/dev/yr$299+/yearMITMIT + manual$995+/year
Styled headersYesManualManualN/AYes
Filtered exportYesManualManualN/AYes
Large datasetsStreamingStreamingIn-memoryN/AStreaming
Lines of code130+30+N/A1

Handling Large Datasets

For grids with 50K+ rows, the export streams data to avoid memory pressure:

@code {
    private async Task ExportLargeDataset()
    {
        await grid.ExportToExcelAsync(new ExcelExportOptions
        {
            FileName = "full-export",
            StreamingThreshold = 10_000 // stream when rows > 10K
        });
    }
}

Server-Side Export

On Blazor Server, the file is generated on the server and streamed to the browser via SignalR. No temporary files, no disk I/O — the XLSX is built in memory and pushed to the client’s download.

Try It

dotnet add package Arcadia.DataGrid

Excel export is included in the Arcadia DataGrid Pro package ($299/dev/year). View pricing.

Ready to try Arcadia?

Start with the free Community edition — 4 chart types, sparklines, notifications, and a full theme engine.