Installation
pnpm add typed-xlsx
npm install typed-xlsx
yarn add typed-xlsx
bun add typed-xlsx
typed-xlsx has no runtime dependencies and ships as ESM only.
The three functions you start from
| Function | Use it to |
|---|---|
createExcelSchema<T>() | describe the report: columns, formulas, styles, summaries |
createWorkbook() | build a workbook from rows you already have in memory |
createWorkbookStream() | build a workbook by committing rows in batches, for large exports |
import { createExcelSchema, createWorkbook } from "typed-xlsx";
type User = { firstName: string; email: string };
const schema = createExcelSchema<User>()
.column("firstName", { header: "First name", accessor: "firstName" })
.column("email", { header: "Email", accessor: "email" })
.build();
const workbook = createWorkbook();
workbook.sheet("Users").table("users", {
rows: [{ firstName: "Ada", email: "ada@example.com" }],
schema,
});
const bytes = workbook.toUint8Array();
Runtimes
Schemas, both builders, toUint8Array() and the streaming builder's Web outputs (toReadableStream(), pipeTo()) run in Node.js, Bun, Deno and edge runtimes such as Cloudflare Workers.
A few outputs depend on Node APIs and load them only when called:
| Needs | Feature |
|---|---|
Node Buffer | toBuffer() |
| Node streams | pipeToNode(), toNodeReadable() |
| a writable filesystem | writeToFile(), and the streaming builder's default temp storage (use tempStorage: "memory" without one) |
The buffered builder (createWorkbook()) compresses the file with Node's zlib, which Node.js, Bun and Deno provide. In runtimes that don't expose it, such as Cloudflare Workers or a browser, the workbook still opens in Excel but its parts are stored uncompressed, so the file is much larger (a 20,000-row, three-column test went from 294 KB to 3.1 MB). The streaming builder compresses with the Web CompressionStream instead, where the runtime has one.
Next steps
- Quick Start: a complete report, buffered and streamed
- Schema Modes: report layout or native Excel table
Introduction
typed-xlsx turns a typed schema into polished XLSX reports, from one row to a million, buffered or streamed, with its own OOXML and ZIP engine.
Quick Start
Build an invoice report with formula columns, a totals row and status badges, then export it buffered and streamed from the same schema.