Pixata.Blazor.Grid.Excel
1.0.0
See the version list below for details.
dotnet add package Pixata.Blazor.Grid.Excel --version 1.0.0
NuGet\Install-Package Pixata.Blazor.Grid.Excel -Version 1.0.0
<PackageReference Include="Pixata.Blazor.Grid.Excel" Version="1.0.0" />
<PackageVersion Include="Pixata.Blazor.Grid.Excel" Version="1.0.0" />
<PackageReference Include="Pixata.Blazor.Grid.Excel" />
paket add Pixata.Blazor.Grid.Excel --version 1.0.0
#r "nuget: Pixata.Blazor.Grid.Excel, 1.0.0"
#:package Pixata.Blazor.Grid.Excel@1.0.0
#addin nuget:?package=Pixata.Blazor.Grid.Excel&version=1.0.0
#tool nuget:?package=Pixata.Blazor.Grid.Excel&version=1.0.0
Pixata.Blazor.Grid.Excel
Excel export for PixataGrid, the data grid in Pixata.Blazor. It's a separate package because it uses ClosedXML, which would otherwise add weight to every app that uses Pixata.Blazor, including WASM apps that don't need it.
Using it
Add the package, add @using Pixata.Blazor.Grid.Excel (in the page or _Imports.razor), and put a PixataGridExcelExport in the grid's GridExport. An ExcelExport command button then saves the grid as an Excel file...
<PixataGrid Data="People" Pageable="true">
<GridToolBarTemplate>
<PixataGridCommandButton Command="ExcelExport" Icon="PixataGridIcon.FileExcel">Export to Excel</PixataGridCommandButton>
</GridToolBarTemplate>
<GridExport>
<PixataGridExcelExport FileName="people" AllPages="true" />
</GridExport>
<GridColumns>...</GridColumns>
</PixataGrid>
You can also export from code, with these extension methods on the grid...
| Method | What it does |
|---|---|
SaveAsExcelFile() |
Exports the grid and has the browser save the file |
ExportToExcel() |
Exports the grid and returns the file as a MemoryStream, or null if OnBeforeExport cancelled it |
Settings
| Parameter | Type | What it does |
|---|---|---|
FileName |
string |
The file name, without ".xlsx". Defaults to "Grid" |
SheetName |
string |
The name of the worksheet. Defaults to "Sheet1" |
AllPages |
bool |
Exports all the rows (filtered and sorted as in the grid), rather than just the page shown. With OnRead, the handler is called with a request for all the rows |
OnBeforeExport |
EventCallback<PixataGridBeforeExportEventArgs<TItem>> |
Fires before the export, with the Columns and Data, which you can change. Set IsCancelled to stop it |
OnAfterExport |
EventCallback<PixataGridAfterExportEventArgs> |
Fires after the export, with the file as a Stream |
What's exported
The columns shown in the grid that have a Field, in the order shown, with their titles as the first row. Command, checkbox and drag columns aren't exported.
- Numbers, dates and true/false values are stored as such, so they can be worked with in Excel. The column's
DisplayFormat(or[DisplayFormat]attribute) is turned into an Excel format where it can be:C,N,F,PandD(with or without a number of decimal places), the standard date formats, custom date formats such as "dd MMM yyyy", and custom number formats such as "#,##0.00". Dates without a format use the current culture's short date format - Everything else is stored as text, formatted with the column's
DisplayFormatif it has one - A column with a
Widthin pixels is that wide in Excel. Other columns are sized to fit their content
ExcelFormats.For(displayFormat, culture) does the format conversion, if you need it yourself.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- ClosedXML (>= 0.105.1)
- Pixata.Blazor (>= 5.0.0)
-
net8.0
- ClosedXML (>= 0.105.1)
- Pixata.Blazor (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.