Pro (paid add-on)
CSV and Excel export
ProExport grid data as CSV or as a real Excel file: the rows people see, in the order they see them, safe to open in any spreadsheet.
Part of Pro
This page documents part of @vjdesigns-pro/ui, the paid add-on package. Using it needs a Pro license and @vjdesigns/vjdesigns-ui 3.8.0 or later. Like the free package, it works in both modes, every brand, all 32 languages and right to left. Install it as described in Account forms.
CSV
Export what people see: getGridRows applies the grid's filter and sort across every page, toCsv turns the rows into CSV text, and downloadCsv saves it as a file.
toCsv(rows, columns, options)writes RFC 4180 text from each column's raw value, not its rendered cell. Fields with the delimiter, quotes or line breaks are quoted.downloadCsv(filename, csv)adds a UTF-8 byte order mark so Excel shows accented and non-Latin text correctly.toCsvandgetGridRowsalso work on the server.
import { downloadCsv, getGridRows, toCsv } from "@vjdesigns-pro/ui";
// What the grid shows (same filter and sort), across every page:
const shown = getGridRows(games, columns, { filter: query, sort });
downloadCsv("season-games.csv", toCsv(shown, columns, { exclude: ["actions"] }));
Safe to open in a spreadsheet
By default toCsv neutralizes text a spreadsheet would run as a formula (starting with =, +, - or @), which protects against CSV injection from user-entered data. Numbers are never changed. Use delimiter: ";" for spreadsheets in locales with a decimal comma.
Excel
downloadXlsx, toXlsx and toXlsxWorkbook write a real .xlsx file with no dependencies (the browser's own compression does the zipping):
- Typed cells: numbers stay numbers, so they sum and sort in Excel;
trueandfalseare booleans;Datevalues and ISO date text become real Excel dates. - Ready to use: a bold header row that stays in view, filter buttons on the header, and column widths fitted to the content.
- Safe with user data: text is always stored as text, never as a formula, so a value like
=HYPERLINK(...)can't run when the file opens. - Sheet names are made valid for Excel and unique ("Roster", "Roster (2)"). A workbook can have several sheets.
- Large exports: 100,000 rows build in under a second.
import { downloadXlsx, getGridRows, toXlsx, toXlsxWorkbook } from "@vjdesigns-pro/ui";
// What the grid shows, as a real Excel file:
await downloadXlsx("season-games", getGridRows(games, columns, { filter: query, sort }), columns, {
name: "Season games",
exclude: ["actions"],
});
// Or build the file yourself (to upload it, say), or several sheets at once:
const blob = await toXlsx(rows, columns);
const workbook = await toXlsxWorkbook([
{ name: "Varsity", rows: varsity, columns },
{ name: "Junior varsity", rows: jv, columns },
]);
Props
CsvOptions
Options for toCsv.
| Prop | Type | Default |
|---|---|---|
delimiterField separator. Use ";" for spreadsheets in locales with a decimal comma. | string | "," |
includeHeadersWrite a header row with each column's header text. | boolean | true |
excludeColumn keys to leave out (an actions column, say). | string[] | — |
formatValueTurns a cell's raw value into text. Defaults: dates as ISO 8601, | (value: unknown, row: T, column: DataGridColumn<T>) => string | — |
escapeFormulasNeutralize cells that a spreadsheet would run as a formula (text starting with | boolean | true |
newlineLine ending. | string | "\r\n" (RFC 4180) |
XlsxSheetOptions
Options for one sheet.
| Prop | Type | Default |
|---|---|---|
nameSheet tab name. Excel allows 31 characters, without | string | "Sheet1" (then "Sheet2", ...) |
includeHeadersWrite a header row with each column's header text. | boolean | true |
excludeColumn keys to leave out (an actions column, say). | string[] | — |
formatValueTurns a cell's raw value into what's written: return a number, boolean, | (value: unknown, row: T, column: DataGridColumn<T>) => unknown | — |
isoDatesAsDatesTreat text like "2026-10-31" (the library's ISO date format, as used by DatePicker) as a real date cell. | boolean | true |
freezeHeaderKeep the header row in view while scrolling, and add filter buttons to it. | boolean | true |
XlsxSheet
One sheet of a workbook.
| Prop | Type | Default |
|---|---|---|
rowsRequired | readonly T[] | — |
columnsRequired | readonly DataGridColumn<T>[] | — |
nameSheet tab name. Excel allows 31 characters, without | string | "Sheet1" (then "Sheet2", ...) |
includeHeadersWrite a header row with each column's header text. | boolean | true |
excludeColumn keys to leave out (an actions column, say). | string[] | — |
formatValueTurns a cell's raw value into what's written: return a number, boolean, | (value: unknown, row: T, column: DataGridColumn<T>) => unknown | — |
isoDatesAsDatesTreat text like "2026-10-31" (the library's ISO date format, as used by DatePicker) as a real date cell. | boolean | true |
freezeHeaderKeep the header row in view while scrolling, and add filter buttons to it. | boolean | true |
XlsxOptions
Options for toXlsx.
| Prop | Type | Default |
|---|---|---|
compressCompress the file (DEFLATE), where the browser supports it. | boolean | true |
nameSheet tab name. Excel allows 31 characters, without | string | "Sheet1" (then "Sheet2", ...) |
includeHeadersWrite a header row with each column's header text. | boolean | true |
excludeColumn keys to leave out (an actions column, say). | string[] | — |
formatValueTurns a cell's raw value into what's written: return a number, boolean, | (value: unknown, row: T, column: DataGridColumn<T>) => unknown | — |
isoDatesAsDatesTreat text like "2026-10-31" (the library's ISO date format, as used by DatePicker) as a real date cell. | boolean | true |
freezeHeaderKeep the header row in view while scrolling, and add filter buttons to it. | boolean | true |