Types
CellStyle
Applied to data cells via style and to header cells via headerStyle.
import type { CellStyle } from "@chronicstone/typed-xlsx";
| Field | Type | Description |
|---|---|---|
font | FontStyle | Font properties. |
fill | FillStyle | Background fill. |
border | BorderStyle | Cell border lines. |
alignment | AlignmentStyle | Text alignment and wrap. |
numFmt | string | Excel number format string. |
FontStyle
| Field | Type | Description |
|---|---|---|
name | string | Font family name (e.g. "Calibri"). |
size | number | Font size in points. |
bold | boolean | Bold text. |
italic | boolean | Italic text. |
underline | boolean | Underline text. |
strike | boolean | Strikethrough text. |
color | { rgb: string } | Font color as a 6-digit hex string (no #). |
FillStyle
| Field | Type | Description |
|---|---|---|
color | { rgb: string } | Background color as a 6-digit hex string (no #). |
BorderStyle
| Field | Type | Description |
|---|---|---|
top | BorderEdge | Top border. |
right | BorderEdge | Right border. |
bottom | BorderEdge | Bottom border. |
left | BorderEdge | Left border. |
BorderEdge
| Field | Type | Description |
|---|---|---|
style | BorderEdgeStyle | Line 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
| Field | Type | Description |
|---|---|---|
horizontal | "left" · "center" · "right" · "fill" · "justify" | Horizontal alignment. |
vertical | "top" · "center" · "bottom" · "justify" | Vertical alignment. |
wrapText | boolean | Wrap 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";
| Field | Type | Description |
|---|---|---|
label | string | Optional label rendered in non-summary columns on the same row. |
init | () => TAcc | Returns the initial accumulator. Called once before the first batch. |
step | (acc: TAcc, row: T, rowIndex: number) => TAcc | Called for each row in each committed batch. |
finalize | (acc: TAcc) => SummaryCellValue | Called once at finalization. Returns the cell value. |
format | string or (value: SummaryCellValue) => string | Excel number format applied to the summary cell. |
style | CellStyle or (value: SummaryCellValue) => CellStyle | Style applied to the summary cell. |
SummaryBuilder<T>
Helper object passed into the callback form of summary.
| Method | Description |
|---|---|
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().
| Field | Type | Default | Description |
|---|---|---|---|
tempStorage | "file" · "memory" | "file" | Where serialized sheet fragments are spooled between commits. |
tempDirectory | string | OS temp dir | Directory 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:
| Value | Description |
|---|---|
"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:
| Preset | Equivalent strings setting | Use 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.
| Field | Type | Description |
|---|---|---|
tablesPerRow | number | Number of tables placed side-by-side before wrapping. Default: 1. |
tableColumnGap | number | Blank columns between tables in the same row. Default: 1. |
tableRowGap | number | Blank rows between table rows. Default: 1. |
freezePane | { rows?: number; columns?: number } | Freeze the first N rows and/or columns. |
rightToLeft | boolean | Enable right-to-left sheet direction. |
WorkbookStream.sheet() accepts the same options.
TableInput<T>
Passed to .table(input) on the buffered builder.
| Field | Type | Description |
|---|---|---|
schema | SchemaDefinition<T> | Built schema. |
rows | T[] | Data rows. |
id | string | Optional table identifier. |
title | string | Optional 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. |
context | SchemaGroupContext<TSchema> | Required only when selected groups declare a context parameter. |
StreamTableInput<T>
Passed to the async .table(input) on the stream builder.
| Field | Type | Description |
|---|---|---|
id | string | Required table identifier. |
schema | SchemaDefinition<T> | Built schema. |
select | { include?: readonly (SchemaColumnId<TSchema> | SchemaGroupId<TSchema>)[]; exclude?: readonly (SchemaColumnId<TSchema> | SchemaGroupId<TSchema>)[] } | Column or group selection by id. |
context | SchemaGroupContext<TSchema> | Required only when selected groups declare a context parameter. |
rows is not present — rows are committed incrementally via .commit({ rows }).