In-memory tabular export. Takes column definitions + rows and produces an
.xlsx or .csv Buffer from one shared workbook, backed by exceljs.
exceljs is intentionally contained to this package so the dependency surface
stays out of apps/web.
import { type ExportColumn, toCsv, toXlsx } from "@repo/tabular-export";
type Row = { name: string; status: string };
const columns: ExportColumn<Row>[] = [
{ header: "Name", value: (row) => row.name },
{ header: "Status", value: (row) => row.status },
];
const rows: Row[] = [{ name: "Al Pacino", status: "fail" }];
const xlsx = await toXlsx({ columns, rows, sheetName: "Report" }); // Buffer
const csv = await toCsv({ columns, rows }); // Buffer
= + - @ / tab / CR get a '
prefix). XLSX cells are typed strings and are not formula-evaluated, so they
are left untouched.All generation is in-memory — nothing is written to disk.