Typed-xlsx
Reference

Types

CellStyle, SummaryDefinition, SchemaDefinition, WorkbookStreamOptions, SheetOptions, and TableInput shapes.

CellStyle

Applied to data cells via style and to header cells via headerStyle.

import type { 
CellStyle
} from "@chronicstone/typed-xlsx";
FieldTypeDescription
fontFontStyleFont properties.
fillFillStyleBackground fill.
borderBorderStyleCell border lines.
alignmentAlignmentStyleText alignment and wrap.
numFmtstringExcel number format string.

FontStyle

FieldTypeDescription
namestringFont family name (e.g. "Calibri").
sizenumberFont size in points.
boldbooleanBold text.
italicbooleanItalic text.
underlinebooleanUnderline text.
strikebooleanStrikethrough text.
color{ rgb: string }Font color as a 6-digit hex string (no #).

FillStyle

FieldTypeDescription
color{ rgb: string }Background color as a 6-digit hex string (no #).

BorderStyle

FieldTypeDescription
topBorderEdgeTop border.
rightBorderEdgeRight border.
bottomBorderEdgeBottom border.
leftBorderEdgeLeft border.

BorderEdge

FieldTypeDescription
styleBorderEdgeStyleLine style (see below).
color{ rgb: string }Border color as a 6-digit hex string.

BorderEdgeStyle values: "thin" · "medium" · "thick" · "dashed" · "dotted" · "double" · "hair" · "dashDot" · "dashDotDot"

AlignmentStyle

FieldTypeDescription
horizontal"left" · "center" · "right" · "fill" · "justify"Horizontal alignment.
vertical"top" · "center" · "bottom" · "justify"Vertical alignment.
wrapTextbooleanWrap text within the cell.

SummaryInput<T>

Passed to the summary field of a column definition.

import type { 
SummaryBuilder
,
SummaryDefinition
,
SummaryInput
} from "@chronicstone/typed-xlsx";

SummaryInput<T> can be:

  • a single SummaryDefinition<T, TAcc>
  • an array of SummaryDefinition<T, TAcc>
  • a callback (summary: SummaryBuilder<T>) => SummaryDefinition[]

The callback form is the recommended public API.


SummaryDefinition<T, TAcc>

import type { 
SummaryDefinition
} from "@chronicstone/typed-xlsx";
FieldTypeDescription
labelstringOptional label rendered in non-summary columns on the same row.
init() => TAccReturns the initial accumulator. Called once before the first batch.
step(acc: TAcc, row: T, rowIndex: number) => TAccCalled for each row in each committed batch.
finalize(acc: TAcc) => SummaryCellValueCalled once at finalization. Returns the cell value.
formatstring or (value: SummaryCellValue) => stringExcel number format applied to the summary cell.
styleCellStyle or (value: SummaryCellValue) => CellStyleStyle applied to the summary cell.

SummaryBuilder<T>

Helper object passed into the callback form of summary.

MethodDescription
cell({...})Creates a reducer-based summary cell.
label("Total")Creates a static string summary cell.
empty()Creates an intentionally blank summary cell for row alignment.

SchemaDefinition<T, TColumnId = string, TGroupId = never, TGroupContext = {}>

The return type of createExcelSchema<T>().build(). Opaque — do not construct manually.

Schemas are frozen after .build() and safe to share across multiple workbooks and threads.

TColumnId carries the compile-time union of known column ids. TGroupId carries the compile-time union of group ids. Both are used to type select.include and select.exclude on the buffered and stream builders.

TGroupContext carries the required shape of the context object for groups whose callback declares a second parameter. If a schema defines .group("orgs", (builder, ctx: Org[]) => ...), table inputs must provide context.orgs when that group is selected.


CellValue

The set of primitive values that can appear in a cell.

type CellValue = string | number | boolean | Date | null | undefined;

Array values (string[], number[]) are accepted by accessor and transform to trigger sub-row expansion. The array element type must be CellValue.


WorkbookStreamOptions

Options for createWorkbookStream().

FieldTypeDefaultDescription
tempStorage"file" · "memory""file"Where serialized sheet fragments are spooled between commits.
tempDirectorystringOS temp dirDirectory for file-backed spools.
strings"auto" · "inline" · "shared""auto"String storage strategy. Overrides memoryProfile.
memoryProfile"balanced" · "low-memory" · "compact-file""balanced"Convenience preset for string strategy.

String strategy meanings:

ValueDescription
"inline"Each string written directly into the cell XML. No shared string table in heap. Produces larger files.
"shared"All strings deduplicated into a shared string table. Smaller output files for repeated values, but the table grows in heap.
"auto"Uses "balanced" preset: shared strings enabled, balanced memory/size trade-off.

memoryProfile presets:

PresetEquivalent strings settingUse when
"balanced""shared"Default. General purpose.
"low-memory""inline"Minimizing heap is the priority.
"compact-file""shared"Minimizing output file size is the priority.

SheetOptions

Options for .sheet(name, options?) on both builders.

FieldTypeDescription
tablesPerRownumberNumber of tables placed side-by-side before wrapping. Default: 1.
tableColumnGapnumberBlank columns between tables in the same row. Default: 1.
tableRowGapnumberBlank rows between table rows. Default: 1.
freezePane{ rows?: number; columns?: number }Freeze the first N rows and/or columns.
rightToLeftbooleanEnable right-to-left sheet direction.

WorkbookStream.sheet() accepts the same options.


TableInput<T>

Passed to .table(input) on the buffered builder.

FieldTypeDescription
schemaSchemaDefinition<T>Built schema.
rowsT[]Data rows.
idstringOptional table identifier.
titlestringOptional title row rendered above the header.
select{ include?: readonly (SchemaColumnId<TSchema> | SchemaGroupId<TSchema>)[]; exclude?: readonly (SchemaColumnId<TSchema> | SchemaGroupId<TSchema>)[] }Column or group selection by id.
contextSchemaGroupContext<TSchema>Required only when selected groups declare a context parameter.

StreamTableInput<T>

Passed to the async .table(input) on the stream builder.

FieldTypeDescription
idstringRequired table identifier.
schemaSchemaDefinition<T>Built schema.
select{ include?: readonly (SchemaColumnId<TSchema> | SchemaGroupId<TSchema>)[]; exclude?: readonly (SchemaColumnId<TSchema> | SchemaGroupId<TSchema>)[] }Column or group selection by id.
contextSchemaGroupContext<TSchema>Required only when selected groups declare a context parameter.

rows is not present — rows are committed incrementally via .commit({ rows }).

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