Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Pro (paid add-on)

CSV and Excel export

Pro

Export 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.
  • toCsv and getGridRows also work on the server.
ts
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; true and false are booleans; Date values 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.
ts
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.

CsvOptions props
PropTypeDefault
delimiter

Field separator. Use ";" for spreadsheets in locales with a decimal comma.

string","
includeHeaders

Write a header row with each column's header text.

booleantrue
exclude

Column keys to leave out (an actions column, say).

string[]—
formatValue

Turns a cell's raw value into text. Defaults: dates as ISO 8601, null / undefined as empty.

(value: unknown, row: T, column: DataGridColumn<T>) => string—
escapeFormulas

Neutralize cells that a spreadsheet would run as a formula (text starting with =, +, -, @, tab, or carriage return) by prefixing a '. Guards against CSV injection when the data came from users. Numbers are never changed.

booleantrue
newline

Line ending.

string"\r\n" (RFC 4180)

XlsxSheetOptions

Options for one sheet.

XlsxSheetOptions props
PropTypeDefault
name

Sheet tab name. Excel allows 31 characters, without \ / ? * [ ] :.

string"Sheet1" (then "Sheet2", ...)
includeHeaders

Write a header row with each column's header text.

booleantrue
exclude

Column keys to leave out (an actions column, say).

string[]—
formatValue

Turns a cell's raw value into what's written: return a number, boolean, Date, or string (written as that type), or null for an empty cell. Defaults to the raw value (column.value(row), else row[key]).

(value: unknown, row: T, column: DataGridColumn<T>) => unknown—
isoDatesAsDates

Treat text like "2026-10-31" (the library's ISO date format, as used by DatePicker) as a real date cell.

booleantrue
freezeHeader

Keep the header row in view while scrolling, and add filter buttons to it.

booleantrue

XlsxSheet

One sheet of a workbook.

XlsxSheet props
PropTypeDefault
rowsRequiredreadonly T[]—
columnsRequiredreadonly DataGridColumn<T>[]—
name

Sheet tab name. Excel allows 31 characters, without \ / ? * [ ] :.

string"Sheet1" (then "Sheet2", ...)
includeHeaders

Write a header row with each column's header text.

booleantrue
exclude

Column keys to leave out (an actions column, say).

string[]—
formatValue

Turns a cell's raw value into what's written: return a number, boolean, Date, or string (written as that type), or null for an empty cell. Defaults to the raw value (column.value(row), else row[key]).

(value: unknown, row: T, column: DataGridColumn<T>) => unknown—
isoDatesAsDates

Treat text like "2026-10-31" (the library's ISO date format, as used by DatePicker) as a real date cell.

booleantrue
freezeHeader

Keep the header row in view while scrolling, and add filter buttons to it.

booleantrue

XlsxOptions

Options for toXlsx.

XlsxOptions props
PropTypeDefault
compress

Compress the file (DEFLATE), where the browser supports it.

booleantrue
name

Sheet tab name. Excel allows 31 characters, without \ / ? * [ ] :.

string"Sheet1" (then "Sheet2", ...)
includeHeaders

Write a header row with each column's header text.

booleantrue
exclude

Column keys to leave out (an actions column, say).

string[]—
formatValue

Turns a cell's raw value into what's written: return a number, boolean, Date, or string (written as that type), or null for an empty cell. Defaults to the raw value (column.value(row), else row[key]).

(value: unknown, row: T, column: DataGridColumn<T>) => unknown—
isoDatesAsDates

Treat text like "2026-10-31" (the library's ISO date format, as used by DatePicker) as a real date cell.

booleantrue
freezeHeader

Keep the header row in view while scrolling, and add filter buttons to it.

booleantrue