> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reducto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# @reductoai/xlsx

The workbook model under the facade: cells, sheets and the calculation engine. `ExcelWorkbook.model` gives it.

## `Workbook`

The workbook's API for registered functions.

Import from `@reductoai/xlsx`.

### Workbook properties

| Name | Type | Description |
| - | - | - |
| `strings` | `StringPool` | read-only |
| `activeSheet` | `number` | read-only Index of the tab Excel opens on. |
| `date1904` | `boolean` | read-only Serials count days from 1904-01-01 (`workbookPr date1904`), as Excel for Mac once did. |
| `definedNames` | `readonly DefinedName[]` | read-only |
| `format` | `WorkbookFormat` | read-only The file kind `save` writes: the opened one, so a macro project or template keeps its extension. |
| `functions` | `readonly XlsxFunction[]` | read-only |
| `idBlock` | `number` | This writer's id block in a shared session (0 alone): new part names, relationship ids, sheet ids and table ids come from `[block * ID_BLOCK + 1, ...)`, so two writers never mint one. |
| `imageLoader` | `ImageLoader \| undefined` | read-only |
| `iteration` | `Iteration \| null` | read-only Excel's iterative calculation settings (`calcPr`); `null` when iteration is off. |
| `iterationLimits` | `Iteration` | read-only The `calcPr` iteration limits, also while iteration is off. |
| `sheetCount` | `number` | read-only |

### `Workbook.create()`

```ts theme={null}
static create(): Workbook
```

A new workbook as Excel makes one: a single empty "Sheet1".

### `Workbook.open()`

```ts theme={null}
static open(bytes: Uint8Array): Workbook
```

### `Workbook.activate()`

```ts theme={null}
activate(index: number): void
```

Makes `index` the open tab and the only selected one.

### `Workbook.addMedia()`

```ts theme={null}
addMedia(
  owner: string,
  bytes: Uint8Array,
  extension: string,
  contentType: string,
): string
```

Stores `bytes` as `xl/media/image<n>.<extension>` related from `owner`; returns the relationship id.

### `Workbook.addPart()`

```ts theme={null}
addPart(part: string, contentType: string, relType: string, owner: string): string
```

Adds a part related from `owner`; returns the relationship id.

### `Workbook.addRelationship()`

```ts theme={null}
addRelationship(owner: string, type: string, target: string, external?: boolean): string
```

Relates `owner` to a part that already exists, or to an external target; returns the id.

### `Workbook.addSheet()`

```ts theme={null}
addSheet(name: string, xml?: string): number
```

### `Workbook.cachedPicture()`

```ts theme={null}
cachedPicture(uid: string, alt?: string): PictureValue | undefined
```

A picture of an image some cell of the workbook holds, by its `PictureValue.cachedUid`.

### `Workbook.calc()`

```ts theme={null}
calc(): WorkbookCalc
```

The calc layer, created on first edit: every sheet loads and every formula registers.

### `Workbook.cellEdited()`

```ts theme={null}
cellEdited(sheet: number, row: number, col: number): void
```

A cell's content changed; a table header renames its column.

### `Workbook.circularReferences()`

```ts theme={null}
circularReferences(): { col: number; row: number; sheet: number }[]
```

Cells whose formula is on a circular reference, by sheet, row and column. Empty with
iteration on, where Excel neither warns nor names a cell.

### `Workbook.copySheet()`

```ts theme={null}
copySheet(index: number, name: string, to: number): number
```

Copies a sheet's cells, formats, merges, rules, links and drawings to a new sheet at `to`,
with its sheet-level names; a chart that reads the sheet reads the copy. Throws for a sheet
with tables, comments, pivot tables or legacy VML.

### `Workbook.defineFunction()`

```ts theme={null}
defineFunction(def: XlsxFunction): void
```

Registers a function formulas call by name; it comes before a defined name of that name.

### `Workbook.deleteDefinedName()`

```ts theme={null}
deleteDefinedName(name: string, sheet?: number | null): boolean
```

Removes a defined name; false when there is none with that name and scope.

### `Workbook.deleteSheet()`

```ts theme={null}
deleteSheet(index: number): void
```

Deletes a worksheet as Excel does: references to it become `#REF!`, names scoped to it go,
a 3D span that ends on it shrinks, and its parts (drawings, comments, tables) are dropped.

### `Workbook.drawings()`

```ts theme={null}
drawings(index: number): DrawingObject[]
```

The sheet's drawing objects in z-order, re-read only when the drawing part changes.

### `Workbook.ensureStyles()`

```ts theme={null}
ensureStyles(): void
```

Writes the style table if the package has none, so every writer of a shared copy starts from the same one.

### `Workbook.freePart()`

```ts theme={null}
freePart(stem: string, ext?: string, taken?: (n: number) => boolean): string
```

`${stem}<n>${ext}` for the first n at or past this writer's floor that names no part.

### `Workbook.functionsSettled()`

```ts theme={null}
functionsSettled(): Promise<void>
```

Resolves when no formula waits for a function's result: call it before `save` to keep every result.

### `Workbook.getSheet()`

```ts theme={null}
getSheet(name: string): Worksheet | undefined
```

### `Workbook.hasPart()`

```ts theme={null}
hasPart(name: string): boolean
```

### `Workbook.importSheet()`

```ts theme={null}
importSheet(source: WorkbookSheets, index: number, name: string, to: number): number
```

Copies `source`'s sheet `index` in as `name` at `to`: cells, formats, rules, drawings and
tables. Comments, pivot tables and controls stay behind, as in Excel on the web.

### `Workbook.markChanged()`

```ts theme={null}
markChanged(index: number): void
```

Marks the sheet for rewrite on save after a style-only edit.

### `Workbook.markDirty()`

```ts theme={null}
markDirty(sheet: number, rect: { c0: number; c1: number; r0: number; r1: number }): void
```

The formulas inside `rect` of sheet `sheet` calculate again at the next recalc.

### `Workbook.moveSheet()`

```ts theme={null}
moveSheet(index: number, to: number): void
```

Moves a worksheet to tab position `to`; only 3D spans that end on it change.

### `Workbook.nameAttr()`

```ts theme={null}
nameAttr(
  name: string,
  sheet: number | null,
  attr: "comment" | "hidden",
): string | undefined
```

A defined name's `comment` or `hidden` attribute; set to null to drop it.

### `Workbook.nextId()`

```ts theme={null}
nextId(ids: Iterable<number>): number
```

One past the largest of `ids` inside this writer's block.

### `Workbook.noteStructure()`

```ts theme={null}
noteStructure(index: number): void
```

Rows, columns or merges of the sheet changed.

### `Workbook.onFunctionResults()`

```ts theme={null}
onFunctionResults(listener: () => void): () => void
```

`listener` runs after function results arrive; read the cells again then. Returns the unsubscribe.

### `Workbook.onShift()`

```ts theme={null}
onShift(watch: ShiftWatch): () => void
```

Calls `watch` after whole rows or columns are inserted (count > 0) or deleted, with the
sheet's part name; a shared session renumbers its cells by it. Returns the unsubscribe.

### `Workbook.partBytes()`

```ts theme={null}
partBytes(name: string): Uint8Array<ArrayBufferLike> | undefined
```

Raw bytes of a package part, such as an image under `xl/media`.

### `Workbook.partRels()`

```ts theme={null}
partRels(name: string): Relationship[]
```

Relationships of a part; internal targets are resolved to part names.

### `Workbook.partText()`

```ts theme={null}
partText(name: string): string
```

Raw text of a package part, or "" when absent; pending style edits are written first.

### `Workbook.peekCalc()`

```ts theme={null}
peekCalc(): WorkbookCalc | undefined
```

The calc layer if it exists; reads do not create it.

### `Workbook.pictureOf()`

```ts theme={null}
pictureOf(vm: number): PictureValue | undefined
```

The picture a cell's value metadata (`vm`) points at.

### `Workbook.pivotTables()`

```ts theme={null}
pivotTables(): PivotInfo[]
```

Every pivot table, read from its parts on each call.

### `Workbook.readCalc()`

```ts theme={null}
readCalc(): WorkbookCalc | undefined
```

The calc layer a value read needs: as `peekCalc`, but a file saved with `fullCalcOnLoad` creates it.

### `Workbook.recalc()`

```ts theme={null}
recalc(full?: boolean): number
```

Recomputes stale formulas; returns how many cells changed value.

### `Workbook.recordOperation()`

```ts theme={null}
recordOperation(name: string, result?: OperationResult): void
```

One editor command on this workbook, for analysis; nothing for an unbilled one.

### `Workbook.refreshFunctions()`

```ts theme={null}
refreshFunctions(name?: string): void
```

Forgets the results of the function `name`, or of every function, so formulas compute them again.

### `Workbook.relatedPart()`

```ts theme={null}
relatedPart(typeSuffix: string): string | undefined
```

The part a workbook relationship of this type points at, e.g. `/styles`.

### `Workbook.removeFunction()`

```ts theme={null}
removeFunction(name: string): boolean
```

Drops a registered function; false when none has that name.

### `Workbook.removePart()`

```ts theme={null}
removePart(name: string): void
```

Drops a part and every part only it related.

### `Workbook.removeRelationship()`

```ts theme={null}
removeRelationship(owner: string, id: string): void
```

### `Workbook.renameDefinedName()`

```ts theme={null}
renameDefinedName(name: string, sheet: number | null, to: string): void
```

Renames a defined name and every formula that reads it, as Excel's Name Manager does.

### `Workbook.renameSheet()`

```ts theme={null}
renameSheet(index: number, name: string): void
```

Renames a sheet and every formula, defined name and chart series that refers to it.

### `Workbook.restore()`

```ts theme={null}
restore(snap: WorkbookSnapshot): void
```

Returns to a snapshot: every sheet reloads and the calc layer is rebuilt on next use.

### `Workbook.restructure()`

```ts theme={null}
restructure(edit: StructureEdit): void
```

Inserts or deletes rows, columns or cells, or cuts cells and pastes them elsewhere, as Excel
does: every formula, defined name, merge, conditional format, validation, hyperlink, comment,
table, chart series and drawing anchor that addresses a moved cell follows it, and one that
addresses a deleted cell becomes `#REF!`.

### `Workbook.rewriteFormulas()`

```ts theme={null}
rewriteFormulas(
  fn: (text: string, sheet: number | null, at?: { col: number; row: number }) => string,
): void
```

Maps every cell, name, table and chart formula through `fn`.

### `Workbook.save()`

```ts theme={null}
save(): Uint8Array
```

Writes back only the sheets that changed; a stale calc chain is dropped.

### `Workbook.sessionHost()`

```ts theme={null}
sessionHost(): SessionHost
```

Reads and writes beneath the editing API, for a shared session.

### `Workbook.setDefinedName()`

```ts theme={null}
setDefinedName(name: string, text: string, sheet?: number | null): void
```

Adds a defined name or gives one new text (file form, no "="); `sheet` scopes it to that worksheet.

### `Workbook.setImageLoader()`

```ts theme={null}
setImageLoader(loader: ImageLoader | undefined): void
```

What `IMAGE` fetches its pictures with. With none, a formula shows the picture the file saved
for its address, or #BLOCKED!: a workbook on a server fetches nothing unless told to.

### `Workbook.setIteration()`

```ts theme={null}
setIteration(patch: { count?: number; delta?: number; enabled?: boolean }): void
```

Turns iteration on or off and sets its limits. As in Excel, the change recalculates: with
iteration on, every circular cell passes up to `count` times.

### `Workbook.setNameAttr()`

```ts theme={null}
setNameAttr(
  name: string,
  sheet: number | null,
  attr: "comment" | "hidden",
  v: string | null,
): void
```

### `Workbook.setPartBytes()`

```ts theme={null}
setPartBytes(name: string, bytes: Uint8Array): void
```

Stores raw bytes as a part; the caller relates it.

### `Workbook.setPartText()`

```ts theme={null}
setPartText(name: string, text: string): void
```

Replaces a part's text; the caller keeps it valid.

### `Workbook.setSheetVisibility()`

```ts theme={null}
setSheetVisibility(index: number, visibility: SheetVisibility): void
```

### `Workbook.settle()`

```ts theme={null}
settle(): void
```

Recalculates only when an edit or a stale formula is pending; a read needs no volatile pass.

### `Workbook.sheet()`

```ts theme={null}
sheet(index: number): Worksheet
```

### `Workbook.sheetIndexOf()`

```ts theme={null}
sheetIndexOf(name: string): number
```

### `Workbook.sheetIndexOfKey()`

```ts theme={null}
sheetIndexOfKey(key: string): number
```

The sheet with this `sheetKey`, or -1 once deleted.

### `Workbook.sheetKey()`

```ts theme={null}
sheetKey(index: number): string
```

A key for a sheet that survives renames, moves and the deletion of other sheets.

### `Workbook.sheetNameOf()`

```ts theme={null}
sheetNameOf(index: number): string
```

### `Workbook.sheetNames()`

```ts theme={null}
sheetNames(): string[]
```

### `Workbook.sheetPartName()`

```ts theme={null}
sheetPartName(index: number): string
```

### `Workbook.sheetVisibility()`

```ts theme={null}
sheetVisibility(index: number): SheetVisibility
```

`Excel.SheetVisibility` of a sheet, from the `state` in workbook.xml.

### `Workbook.snapshot()`

```ts theme={null}
snapshot(): WorkbookSnapshot
```

The whole workbook as it stands, for `restore`; parts are shared, not copied.

### `Workbook.styles()`

```ts theme={null}
styles(): StyleBook
```

The editable style table; created on first use, written back on save.

### `Workbook.tableCellsEdited()`

```ts theme={null}
tableCellsEdited(sheet: number, area: Area, typed: boolean): void
```

Cells in `area` were written or cleared as a user does it; `typed` is one cell entered.
A table's calculated columns follow as in Excel.

### `Workbook.tableEditor()`

```ts theme={null}
tableEditor(): TableEditor
```

Table edits; stale formulas are computed first so a rebuild keeps current values.

### `Workbook.tableLookup()`

```ts theme={null}
tableLookup(sheet: number | null): TableLookup
```

### `Workbook.tables()`

```ts theme={null}
tables(): readonly TableInfo[]
```

Every table of every worksheet, in sheet order.

### `Workbook.takeChanges()`

```ts theme={null}
takeChanges(): Changes
```

Cells, sheet structure and parts changed since the last call; a view redraws from these.

### `Workbook.watchChanges()`

```ts theme={null}
watchChanges(limit?: number): ChangeWatch
```

A reader of the same edits apart from the view's: its `take` leaves `takeChanges` whole.

### `Workbook.workbookPartText()`

```ts theme={null}
workbookPartText(): string
```

## `Worksheet`

One sheet; rows and columns are zero-based.

Import from `@reductoai/xlsx`.

### Worksheet properties

| Name | Type | Description |
| - | - | - |
| `host` | `WorksheetHost` | read-only |
| `index` | `number` | read-only |
| `meta` | `SheetMeta` | read-only |
| `store` | `SheetStore` | read-only |
| `merges` | `readonly Readonly<Rect>[]` | read-only |
| `name` | `string` | read-only |

### `Worksheet.clear()`

```ts theme={null}
clear(row: number, col: number): void
```

### `Worksheet.column()`

```ts theme={null}
column(col: number): Readonly<ColSpan> | undefined
```

The column span covering `col`; widths are in characters.

### `Worksheet.fillFormula()`

```ts theme={null}
fillFormula(rect: Readonly<Rect>, text: string): void
```

One formula over a block, its relative references moving with each cell as Ctrl+Enter does.

### `Worksheet.formula()`

```ts theme={null}
formula(row: number, col: number): string | null
```

Formula as Excel shows it, or null; a shared-formula child prints its master's formula from its own cell.

### `Worksheet.hiddenRows()`

```ts theme={null}
hiddenRows(first: number, last: number): number
```

How many rows of `first`..`last` are hidden.

### `Worksheet.merge()`

```ts theme={null}
merge(rect: Rect): void
```

Replaces any merge that overlaps `rect`, as `Range.merge` does.

### `Worksheet.picture()`

```ts theme={null}
picture(row: number, col: number): PictureValue | undefined
```

The picture in the cell as stored: Excel's Place in Cell, or a formula's picture result.

### `Worksheet.row()`

```ts theme={null}
row(row: number): Readonly<RowProps> | undefined
```

### `Worksheet.setArrayFormula()`

```ts theme={null}
setArrayFormula(
  rect: { c0: number; c1: number; r0: number; r1: number },
  text: string,
): void
```

A legacy (Ctrl+Shift+Enter) array formula over `rect`.

### `Worksheet.setColumns()`

```ts theme={null}
setColumns(first: number, last: number, patch: ColPatch): void
```

### `Worksheet.setDataTable()`

```ts theme={null}
setDataTable(
  rect: { c0: number; c1: number; r0: number; r1: number },
  attrs: string,
): void
```

A What-If data table over `rect`, its result cells; `attrs` is the `<f t="dataTable">`.

### `Worksheet.setFormula()`

```ts theme={null}
setFormula(row: number, col: number, text: string): void
```

Throws `ParseError` or `LexError` when the text is not a formula we read.

### `Worksheet.setRow()`

```ts theme={null}
setRow(row: number, patch: RowPatch): void
```

### `Worksheet.setRowIndexes()`

```ts theme={null}
setRowIndexes(): Iterable<number>
```

Rows with properties of their own, in no order.

### `Worksheet.setRows()`

```ts theme={null}
setRows(first: number, last: number, patch: RowPatch): void
```

Patches rows `first`..`last`; a change in visibility recalculates SUBTOTAL once.

### `Worksheet.setStyle()`

```ts theme={null}
setStyle(row: number, col: number, xf: number, keep?: boolean): void
```

Sets a cell's xf; a blank cell left with its row's or column's xf goes, unless `keep`.

### `Worksheet.setValue()`

```ts theme={null}
setValue(row: number, col: number, v: Scalar): void
```

A `PictureValue` places a picture in the cell, as Insert > Picture > Place in Cell does.

### `Worksheet.shownFormula()`

```ts theme={null}
shownFormula(row: number, col: number): string | null
```

The formula as Excel shows it in its cell: in a table, references to its own columns drop its name.

### `Worksheet.spillArea()`

```ts theme={null}
spillArea(row: number, col: number): Rect | null
```

The area a dynamic array covers when the cell is its anchor or one it spills into; null outside one or before calc runs.

### `Worksheet.styleAt()`

```ts theme={null}
styleAt(row: number, col: number): number
```

The xf a cell shows: its own, else its row's (`customFormat`), else its column's, else 0.

### `Worksheet.unmerge()`

```ts theme={null}
unmerge(rect: Rect): void
```

### `Worksheet.value()`

```ts theme={null}
value(row: number, col: number): Scalar
```

Current value; a formula made stale by an edit is recomputed first.

## `WorkbookCalc`

The workbook side: stored values, defined names, and where results go.

Import from `@reductoai/xlsx`.

### WorkbookCalc properties

| Name | Type | Description |
| - | - | - |
| `cellInfo` | `((type: string, at: CellAt \| null) => Value \| undefined) \| undefined` | read-only CELL's formatting types for a cell, INFO's workbook answers with `at` null; undefined when unknown. |
| `custom` | `((name: string) => FunctionImpl \| undefined) \| undefined` | read-only A function the workbook's host registered; it comes before a defined name of that name. |
| `date1904` | `boolean` | Serial 0 is 1904-01-01 (`workbookPr date1904`), not the 1900 system's 1900-01-00. |
| `engine` | `Engine` | read-only |
| `image` | `((address: string) => Uint8Array<ArrayBufferLike> \| XlError) \| undefined` | read-only `IMAGE`'s picture at an https address: #BUSY! while it loads, #CONNECT! when it cannot. |
| `pivotData` | `((at: CellAt, data: string, pairs: [string, Scalar][]) => Value) \| undefined` | read-only GETPIVOTDATA's lookup in the pivot table at `at`. |
| `roundResult` | `((sheet: number, row: number, col: number, v: number) => number) \| undefined` | Precision as displayed: a formula result keeps only the digits its format shows. |
| `unsupported` | `Map<string, number>` | read-only Formulas left out of the engine, by reason; their cached values stay. |
| `writing` | `boolean` | True while a result is written back, so the change log can tell it from an edit. |

### `WorkbookCalc.addSheet()`

```ts theme={null}
addSheet(model: SheetModel): void
```

Registers a sheet added after the calc layer was built.

### `WorkbookCalc.barrier()`

```ts theme={null}
barrier(sheet: number, row: number, col: number): number
```

A cell no spill may cover: `SPILL_TABLE` inside a table, `SPILL_MERGED` in a merged area, else 0.

### `WorkbookCalc.barriersChanged()`

```ts theme={null}
barriersChanged(
  sheet: number | null,
  blocked?: ReadonlySet<number> | ReadonlyMap<number, unknown>,
): void
```

Merges or tables moved: every spill on `sheet` that covers, or tried to cover, more than its anchor runs again.

### `WorkbookCalc.cellLoaded()`

```ts theme={null}
cellLoaded(sheet: number, row: number, col: number): void
```

The cell was rewritten in the store from outside (a shared session): links it again and recalculates what reads it.

### `WorkbookCalc.cellLoading()`

```ts theme={null}
cellLoading(sheet: number, row: number, col: number, outputs?: boolean): void
```

Splits the shared formula the cell belongs to into its own formulas, before the cell is rewritten.

### `WorkbookCalc.clear()`

```ts theme={null}
clear(sheet: number, row: number, col: number): void
```

### `WorkbookCalc.clearResults()`

```ts theme={null}
clearResults(sheet: number): void
```

Clears what every array formula on the sheet put in cells other than its own; a recalc puts it back.

### `WorkbookCalc.collapseSpills()`

```ts theme={null}
collapseSpills(sheets: readonly number[]): void
```

Shrinks every spill on `sheets` to its anchor: spilled values are results, not cells a move or shift carries.

### `WorkbookCalc.column()`

```ts theme={null}
column(sheet: number, col: number): readonly Scalar[] | null
```

One column's values indexed by row (blank past the end), after pulling rows r0..r1; null when the source keeps none.

### `WorkbookCalc.extent()`

```ts theme={null}
extent(sheet: number): { cols: number; rows: number }
```

Rows and columns in use; nothing outside holds a value.

### `WorkbookCalc.filterChanged()`

```ts theme={null}
filterChanged(sheet: number): void
```

A filter on the sheet was set or cleared: hidden rows may count as filtered now.

### `WorkbookCalc.formulaText()`

```ts theme={null}
formulaText(sheet: number, row: number, col: number): string | null
```

Formula text with `=`, or null for a constant; a shared-formula child prints its master's formula from its own cell.

### `WorkbookCalc.functionsChanged()`

```ts theme={null}
functionsChanged(upper: string): void
```

A function was registered or dropped: formulas that call it link and calculate again.

### `WorkbookCalc.name()`

```ts theme={null}
name(name: string, sheet: number): Expr | null
```

A defined name's formula, or null when none is in scope.

### `WorkbookCalc.namesChanged()`

```ts theme={null}
namesChanged(names: readonly DefinedName[]): void
```

The defined names changed: every formula that may read one is relinked and recalculated.

### `WorkbookCalc.parseAt()`

```ts theme={null}
parseAt(sheet: number, text: string, row: number, col: number): Expr | null
```

Formula text no cell holds, anchored at (row, col); null when it does not parse.

### `WorkbookCalc.read()`

```ts theme={null}
read(sheet: number, row: number, col: number): Scalar
```

### `WorkbookCalc.referencesChanged()`

```ts theme={null}
referencesChanged(): void
```

A sheet was renamed: INDIRECT text that names it resolves again.

### `WorkbookCalc.rowFiltered()`

```ts theme={null}
rowFiltered(sheet: number, row: number): boolean
```

Whether a row is hidden by a filter, for SUBTOTAL 1-11.

### `WorkbookCalc.rowHidden()`

```ts theme={null}
rowHidden(sheet: number, row: number): boolean
```

Whether a row is hidden, for SUBTOTAL 101-111.

### `WorkbookCalc.rowVisibilityChanged()`

```ts theme={null}
rowVisibilityChanged(): void
```

### `WorkbookCalc.savesAsArray()`

```ts theme={null}
savesAsArray(sheet: number, row: number, col: number): boolean
```

The cell's formula is stored as a dynamic array (`t="array"` with `cm`).

### `WorkbookCalc.scan()`

```ts theme={null}
scan(
  sheet: number,
  r0: number,
  c0: number,
  r1: number,
  c1: number,
  visit: (row: number, col: number, v: Scalar) => void,
): void
```

Present cells inside the rectangle, row-major; absent cells are blank.

### `WorkbookCalc.setArrayFormula()`

```ts theme={null}
setArrayFormula(sheet: number, area: Readonly<Box>, text: string): void
```

A legacy (Ctrl+Shift+Enter) array formula over the area; its cells must not hold one already.

### `WorkbookCalc.setDataTable()`

```ts theme={null}
setDataTable(sheet: number, area: Readonly<Box>, attrs: string): void
```

What-If Analysis > Data Table: `attrs` is the `<f t="dataTable">` over `area`, the result cells.

### `WorkbookCalc.setFormula()`

```ts theme={null}
setFormula(sheet: number, row: number, col: number, text: string): void
```

### `WorkbookCalc.setValue()`

```ts theme={null}
setValue(sheet: number, row: number, col: number, v: Scalar): void
```

### `WorkbookCalc.sheetCount()`

```ts theme={null}
sheetCount(): number
```

Worksheets in the workbook, for SHEETS.

### `WorkbookCalc.sheetIndex()`

```ts theme={null}
sheetIndex(name: string): number
```

Worksheet index by name for INDIRECT; -1 when there is none.

### `WorkbookCalc.sheetName()`

```ts theme={null}
sheetName(i: number): string
```

### `WorkbookCalc.spill()`

```ts theme={null}
spill(sheet: number, row: number, col: number): RangeValue | null
```

The range a formula at the cell spills into, or null when it is not a spilling anchor.

### `WorkbookCalc.spilled()`

```ts theme={null}
spilled(f: Formula, blocked: boolean): void
```

Keeps a dynamic formula's `ref` on its area; a typed one becomes a dynamic array once it needs to be.

### `WorkbookCalc.storedFormula()`

```ts theme={null}
storedFormula(
  sheet: number,
  text: string,
  row: number,
  col: number,
): { array: boolean; text: string }
```

`text` at the cell as the file stores it, and whether it is a dynamic-array formula.

### `WorkbookCalc.write()`

```ts theme={null}
write(sheet: number, row: number, col: number, v: Scalar, rich?: RichError): void
```

`null` clears a cell a spill no longer covers; `rich` comes with a #SPILL! or #CALC! a formula made.

## `blankWorkbookBytes()`

```ts theme={null}
function blankWorkbookBytes(): Uint8Array
```

The package of a new Excel workbook with one empty sheet, "Sheet1".

Import from `@reductoai/xlsx/blank`.
