BbDataGrid has no export. It is small, self-contained, and the thing every grid consumer asks for eventually.
Proposed shape
<BbDataGrid ShowExport="true" ExportFileName="employees.csv" />
Plus ExportAsync() on the grid reference for programmatic use (export from a toolbar button, or on a schedule).
The decisions that matter
- Export what the user sees. Visible, sorted and filtered rows — not the raw source collection. Exporting the unfiltered set is the usual complaint about grid export, and it surprises people at exactly the wrong moment.
- Use display values, not raw properties. A column showing
Active via a CellTemplate must export Active, not 3. This means export has to consume the selector from #463, which is why that one should land first.
- Respect column visibility and order, including any reordering the user has done.
- Server-side data. With
ItemsProvider the grid only holds the current page. Either export the current page and say so, or add an opt-in "fetch all for export" path with a row cap. Needs deciding rather than defaulting.
Security — CSV injection
A cell whose value starts with =, +, - or @ is interpreted as a formula when the file is opened in Excel or Sheets. That is a real and well-known attack path: an attacker who can get text into a row can get a formula executed on the machine of whoever exports and opens the file.
Values starting with those characters must be prefixed with an apostrophe on the way out. Worth a test, because it is the kind of thing that gets refactored away later by someone who reads it as cosmetic.
Out of scope
Excel (.xlsx) and PDF. Both need a dependency, and nothing reported so far asks for them. CSV covers the need; the others can follow if demand appears.
Part of the DataGrid sweep — see the plan for ordering against #463, #456 and #412.
BbDataGridhas no export. It is small, self-contained, and the thing every grid consumer asks for eventually.Proposed shape
Plus
ExportAsync()on the grid reference for programmatic use (export from a toolbar button, or on a schedule).The decisions that matter
Activevia aCellTemplatemust exportActive, not3. This means export has to consume the selector from #463, which is why that one should land first.ItemsProviderthe grid only holds the current page. Either export the current page and say so, or add an opt-in "fetch all for export" path with a row cap. Needs deciding rather than defaulting.Security — CSV injection
A cell whose value starts with
=,+,-or@is interpreted as a formula when the file is opened in Excel or Sheets. That is a real and well-known attack path: an attacker who can get text into a row can get a formula executed on the machine of whoever exports and opens the file.Values starting with those characters must be prefixed with an apostrophe on the way out. Worth a test, because it is the kind of thing that gets refactored away later by someone who reads it as cosmetic.
Out of scope
Excel (
.xlsx) and PDF. Both need a dependency, and nothing reported so far asks for them. CSV covers the need; the others can follow if demand appears.Part of the DataGrid sweep — see the plan for ordering against #463, #456 and #412.