Export
Since 0.1.0-alpha.20Download what's on screen as Excel or CSV.
Static server-side rendering: no circuit, no WebAssembly.
Export to Excel
ExportExcelHref adds a link to an endpoint you map with DataExport.WriteExcelAsync, which streams rows from the database with flat memory. The link carries the filter, sort, search and visible columns, and works with no script. The fields you give DataExport decide what can be written, whatever the address says, and their captions head the file. Give them the grid's keys so a download matches the screen: a filter on a key they don't have matches nothing.
Preview
Code
@* The usual setup: Excel alone, one icon that downloads. Sort or page it, then download: the file has
every matching row, in the columns on screen. The endpoint is in the app: DataExport.WriteExcelAsync,
in Results.Stream. *@
Rows = IzzyBlazor.Site.Examples.Table.Orders
<DataGrid Items="Rows.All" PageSize="5" Caption="Orders for Excel" ExportExcelHref="/examples/orders.xlsx" QueryPrefix="excel-" Grow>
<PropertyColumn Property="o => o.Number" Align="CellAlign.Start" Width="6.Rem" />
<PropertyColumn Property="o => o.Customer" Sortable />
<PropertyColumn Property="o => o.Total" Format="C" Sortable Width="8.Rem" />
</DataGrid>Excel and CSV
Add ExportCsvHref to offer CSV too: one button with a chevron then opens a menu of both, Excel first.
Preview
Code
@* With CSV as well as Excel, one button with a chevron opens a menu of both. The endpoints are in the
app: DataExport.WriteExcelAsync and WriteCsvAsync, in Results.Stream. *@
Rows = IzzyBlazor.Site.Examples.Table.Orders
<DataGrid Items="Rows.All" PageSize="5" Caption="Orders to export" ExportExcelHref="/examples/orders.xlsx" ExportCsvHref="/examples/orders.csv" QueryPrefix="export-" Grow>
<PropertyColumn Property="o => o.Number" Align="CellAlign.Start" Width="6.Rem" />
<PropertyColumn Property="o => o.Customer" Sortable />
<PropertyColumn Property="o => o.Total" Format="C" Sortable Width="8.Rem" />
</DataGrid>