Getting Started
Installation
Install typed-xlsx with npm, pnpm, yarn, or bun.
Install the package with your package manager of choice:
pnpm add @chronicstone/typed-xlsx
The main surface is now:
createExcelSchema()to describe columnscreateWorkbook()for buffered exportscreateWorkbookStream()for commit-based large exports
import { createExcelSchema, createWorkbook, createWorkbookStream } from "@chronicstone/typed-xlsx";
type User = {
email: string;
firstName: 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({
rows: [{ firstName: "Ada", email: "ada@example.com" }],
schema,
});
const streamWorkbook = createWorkbookStream({
memoryProfile: "low-memory",
});
Use the buffered builder when the dataset is reasonably sized and you want full workbook composition. Use the stream builder when you want to commit batches and send the XLSX to a file, a Node writable, or another streaming destination.