Typed-xlsx
Workbook Builder

Output

Finalizing a workbook to a buffer, Uint8Array, or file.

The buffered and stream builders finalize differently.

Buffered outputs

import { 
createExcelSchema
,
createWorkbook
} from "@chronicstone/typed-xlsx";
const
schema
=
createExcelSchema
<{
value
: string }>()
.
column
("value", {
accessor
: "value" })
.
build
();
const
workbook
=
createWorkbook
();
workbook
.
sheet
("Logs").
table
({
rows
: [{
value
: "line-1" }],
schema
,
}); const
bytes
=
workbook
.
toUint8Array
();
const
buffer
=
workbook
.
toBuffer
();
await
workbook
.
writeToFile
("./report.xlsx");

Stream outputs

import { 
createWorkbookStream
} from "@chronicstone/typed-xlsx";
const
workbook
=
createWorkbookStream
({
tempStorage
: "file",
strings
: "inline",
}); await
workbook
.
writeToFile
("./report.xlsx");

The stream builder also supports native stream-friendly output shapes:

import { 
createExcelSchema
,
createWorkbookStream
} from "@chronicstone/typed-xlsx";
const
schema
=
createExcelSchema
<{
value
: string }>()
.
column
("value", {
accessor
: "value" })
.
build
();
const
workbook
=
createWorkbookStream
();
const
table
= await
workbook
.
sheet
("Logs").
table
({
id
: "logs",
schema
,
}); await
table
.
commit
({
rows
: [{
value
: "line-1" }],
}); const
readable
=
workbook
.
toNodeReadable
();
const
destination
=
process
.
stdout
;
await
workbook
.
pipeToNode
(
destination
);

That makes it straightforward to pipe XLSX output into HTTP responses, upload helpers, or multipart storage flows after you finish committing your batches.

Copyright © 2026 Cyprien Thao. Released under the MIT License.