API reference

Worksheet

Worksheet shape and the cell / row / column helpers built on top of it.

127 exports · 16 source files

Worksheet

src/worksheet/worksheet.ts

# addCellWatch function

src/worksheet/worksheet.ts:2163

Pin a cell to the Watch Window. Returns the pushed entry.

function addCellWatch(ws: Worksheet, watch: CellWatch): CellWatch

Parameters

NameTypeDescription
ws Worksheet
watch CellWatch

Returns

CellWatch

# addConditionalFormatting function

src/worksheet/worksheet.ts:2143

Append a conditional formatting block.

function addConditionalFormatting(ws: Worksheet, cf: ConditionalFormatting): ConditionalFormatting

Parameters

NameTypeDescription
ws Worksheet
cf ConditionalFormatting

Returns

ConditionalFormatting

# addDataValidation function

src/worksheet/worksheet.ts:1984

Append a DataValidation entry.

function addDataValidation(ws: Worksheet, dv: DataValidation): DataValidation

Parameters

NameTypeDescription
ws Worksheet
dv DataValidation

Returns

DataValidation

# addIgnoredError function

src/worksheet/worksheet.ts:2176

Append an ignored-error region.

function addIgnoredError(ws: Worksheet, ie: IgnoredError): IgnoredError

Parameters

NameTypeDescription
ws Worksheet
ie IgnoredError

Returns

IgnoredError

# addTable function

src/worksheet/worksheet.ts:2027

Append a table. The id and displayName must be workbook-unique — the caller is responsible.

function addTable(ws: Worksheet, table: TableDefinition): TableDefinition

Parameters

NameTypeDescription
ws Worksheet
table TableDefinition

Returns

TableDefinition

# appendRow function

src/worksheet/worksheet.ts:353

Append a row of values starting at the next empty row. Returns the row index (1-based). Mirrors openpyxl's `Worksheet.append`. `null` / `undefined` entries leave the cell empty.

function appendRow(ws: Worksheet, values: readonly (CellValue | undefined)[]): number

Parameters

NameTypeDescription
ws Worksheet
values readonly (CellValue | undefined)[]

Returns

number

# appendRows function

src/worksheet/worksheet.ts:374

Bulk version of appendRow: append a 2D array of values one row at a time. Returns `{firstRow, lastRow}` — both 1-based, inclusive. An empty input returns `{firstRow, lastRow: firstRow - 1}` so callers can detect the no-op without throwing. Common usage: `appendRows(ws, csvParsedRows)` for fast import.

function appendRows(ws: Worksheet, rows: readonly readonly (CellValue | undefined)[][]): { firstRow: number; lastRow: number }

Parameters

NameTypeDescription
ws Worksheet
rows readonly readonly (CellValue | undefined)[][]

Returns

{ firstRow: number; lastRow: number }

# applyToRange function

src/worksheet/worksheet.ts:1210

Iterate over every cell coordinate in a range, calling `visit` once per (row, col). Allocates the cell on first touch so callers can mutate it freely.

function applyToRange(ws: Worksheet, range: string, visit: (cell: Cell, row: number, col: number) => void): void

Parameters

NameTypeDescription
ws Worksheet
range string
visit (cell: Cell, row: number, col: number) => void

Returns

void

# autofitColumns function

src/worksheet/worksheet.ts:1776

Approximate autofit for every column with at least one populated cell. Walks the worksheet once collecting per-column widest-length + applies autofitColumn per column. `opts.workbook` enables font-size-aware scaling; without it the helper falls back to plain string length.

function autofitColumns(ws: Worksheet, opts?: { max?: number; min?: number; padding?: number; workbook?: { styles: { cellXfs: readonly { fontId: number }[]; fonts: readonly { size?: number }[] } } }): void

Parameters

NameTypeDescription
ws Worksheet
opts? = {}{ max?: number; min?: number; padding?: number; workbook?: { styles: { cellXfs: readonly { fontId: number }[]; fonts: readonly { size?: number }[] } } }

Returns

void

# clearAllCells function

src/worksheet/worksheet.ts:340

Wipe every populated cell on the worksheet, leaving styles, dimensions, merges, comments, hyperlinks etc. intact. Returns the count of cells removed. Useful when a sheet should be re-filled from scratch but its formatting kept.

function clearAllCells(ws: Worksheet): number

Parameters

NameTypeDescription
ws Worksheet

Returns

number

# clearRange function

src/worksheet/worksheet.ts:321

Delete every populated cell inside a range. Returns the number of cells removed. Row maps that go empty are pruned. Column / row dimensions, merges, comments etc. are left untouched.

function clearRange(ws: Worksheet, range: string): number

Parameters

NameTypeDescription
ws Worksheet
range string

Returns

number

# collapseColumnGroup function

src/worksheet/worksheet.ts:1678

Collapse a column outline group: hide + mark `collapsed: true` for every column in `[fromCol, toCol]`. Columns must already carry an `outlineLevel` from groupColumns for the collapse to render correctly.

function collapseColumnGroup(ws: Worksheet, fromCol: number, toCol: number): void

Parameters

NameTypeDescription
ws Worksheet
fromCol number
toCol number

Returns

void

# collapseRowGroup function

src/worksheet/worksheet.ts:1646

Collapse a row outline group: hide every row in `[fromRow, toRow]` and mark them `collapsed: true`. Mirrors Excel's `−` button on a grouped row strip. Rows must already carry an `outlineLevel` from groupRows for the collapse to render correctly.

function collapseRowGroup(ws: Worksheet, fromRow: number, toRow: number): void

Parameters

NameTypeDescription
ws Worksheet
fromRow number
toRow number

Returns

void

# copyRange function

src/worksheet/worksheet.ts:1259

Copy every populated cell from `source` to `target` (within the same worksheet, or across worksheets via `targetWs`). Cells are shallow-cloned: `value` and `styleId` carry over but `row`/`col` are rewritten. The target's existing cells in the destination extent are overwritten; cells outside are untouched. The source and target ranges define the top-left corner — their dimensions need not match. If the target range is smaller than the source, only the cells that fit within the target's extent are copied; if larger, only the source's extent is filled. Returns the number of cells copied.

function copyRange(ws: Worksheet, source: string, target: string, opts?: { targetWs?: Worksheet }): number

Parameters

NameTypeDescription
ws Worksheet
source string
target string
opts? = {}{ targetWs?: Worksheet }

Returns

number

# countCells function

src/worksheet/worksheet.ts:666

Total populated cell count.

function countCells(ws: Worksheet): number

Parameters

NameTypeDescription
ws Worksheet

Returns

number

# countCellsByKind function

src/worksheet/worksheet.ts:583
function countCellsByKind(ws: Worksheet): CellsByKindCounts

Parameters

NameTypeDescription
ws Worksheet

Returns

CellsByKindCounts

# deleteCell function

src/worksheet/worksheet.ts:309

Delete a single cell from the sheet. Empty rows are pruned.

function deleteCell(ws: Worksheet, row: number, col: number): void

Parameters

NameTypeDescription
ws Worksheet
row number
col number

Returns

void

# expandColumnGroup function

src/worksheet/worksheet.ts:1692

Expand a column outline group: drop `hidden` and `collapsed` from every column in `[fromCol, toCol]`. Leaves `outlineLevel` intact.

function expandColumnGroup(ws: Worksheet, fromCol: number, toCol: number): void

Parameters

NameTypeDescription
ws Worksheet
fromCol number
toCol number

Returns

void

# expandRowGroup function

src/worksheet/worksheet.ts:1660

Expand a row outline group: drop the `hidden` and `collapsed` flags on every row in `[fromRow, toRow]`. Leaves `outlineLevel` and other dimensions intact.

function expandRowGroup(ws: Worksheet, fromRow: number, toRow: number): void

Parameters

NameTypeDescription
ws Worksheet
fromRow number
toRow number

Returns

void

# findCells function

src/worksheet/worksheet.ts:720

Iterate every populated cell, yielding those for which `predicate` returns true. Iteration order is row-then-column ascending. Cells whose `.value === null` (empty placeholders carrying only style or comment metadata) are still visited.

function findCells(ws: Worksheet, predicate: (c: Cell) => boolean): IterableIterator<Cell>

Parameters

NameTypeDescription
ws Worksheet
predicate (c: Cell) => boolean

Returns

IterableIterator<Cell>

# freezePanes function

src/worksheet/worksheet.ts:1044

Freeze both top `rows` rows AND left `cols` columns.

function freezePanes(ws: Worksheet, rows: number, cols: number): void

Parameters

NameTypeDescription
ws Worksheet
rows number
cols number

Returns

void

# getAutoFilter function

src/worksheet/worksheet.ts:2020

Read the current AutoFilter, if any.

function getAutoFilter(ws: Worksheet): AutoFilter | undefined

Parameters

NameTypeDescription
ws Worksheet

Returns

AutoFilter | undefined

# getCell function

src/worksheet/worksheet.ts:280

Resolve a 1-based or "A1" coordinate; returns the populated Cell or undefined.

function getCell(ws: Worksheet, row: number, col: number): Cell | undefined

Parameters

NameTypeDescription
ws Worksheet
row number
col number

Returns

Cell | undefined

# getCellByCoord function

src/worksheet/worksheet.ts:883

Convenience getter accepting an "A1" coordinate.

function getCellByCoord(ws: Worksheet, coord: string): Cell | undefined

Parameters

NameTypeDescription
ws Worksheet
coord string

Returns

Cell | undefined

# getCellsInColumn function

src/worksheet/worksheet.ts:1439

Enumerate the populated cells of a column in row order. Walks the row map and collects whichever rows carry the column. Returns `[]` when the worksheet has no cell in that column.

function getCellsInColumn(ws: Worksheet, col: number): Cell[]

Parameters

NameTypeDescription
ws Worksheet
col number

Returns

Cell[]

# getCellsInRange function

src/worksheet/worksheet.ts:805

Iterate the populated cells inside a rectangular range. Cells that don't exist in the sparse store are skipped (no auto-allocate). Use applyToRange when you need every coordinate visited regardless of population.

function getCellsInRange(ws: Worksheet, range: string): IterableIterator<Cell>

Parameters

NameTypeDescription
ws Worksheet
range string

Returns

IterableIterator<Cell>

# getCellsInRow function

src/worksheet/worksheet.ts:1422

Enumerate the populated cells of a row in column order. Unlike getRowValues, this skips empty columns and yields the cell objects (not just their values). Returns `[]` when the row is absent or empty.

function getCellsInRow(ws: Worksheet, row: number): Cell[]

Parameters

NameTypeDescription
ws Worksheet
row number

Returns

Cell[]

# getColumnDimension function

src/worksheet/worksheet.ts:1456

Look up the ColumnDimension covering `col`. The search walks every registered entry's `min..max` range; that's fine for the typical spreadsheet (a handful of column entries) and stays simple.

function getColumnDimension(ws: Worksheet, col: number): ColumnDimension | undefined

Parameters

NameTypeDescription
ws Worksheet
col number

Returns

ColumnDimension | undefined

# getDataExtent function

src/worksheet/worksheet.ts:677

Bounding-box of the populated cells: `{ minRow, maxRow, minCol, maxCol }` covering every cell in `ws.rows`. Returns `undefined` when the sheet is empty. Walks the sparse store once.

function getDataExtent(ws: Worksheet): { maxCol: number; maxRow: number; minCol: number; minRow: number } | undefined

Parameters

NameTypeDescription
ws Worksheet

Returns

{ maxCol: number; maxRow: number; minCol: number; minRow: number } | undefined

# getFreezePanes function

src/worksheet/worksheet.ts:1014

Inverse of setFreezePanes; returns the top-left ref or undefined when no freeze is active.

function getFreezePanes(ws: Worksheet): string | undefined

Parameters

NameTypeDescription
ws Worksheet

Returns

string | undefined

# getMaxCol function

src/worksheet/worksheet.ts:502

Effective max column index based on populated cells (0 when empty).

function getMaxCol(ws: Worksheet): number

Parameters

NameTypeDescription
ws Worksheet

Returns

number

# getMaxRow function

src/worksheet/worksheet.ts:495

Effective max row index based on populated cells (0 when empty).

function getMaxRow(ws: Worksheet): number

Parameters

NameTypeDescription
ws Worksheet

Returns

number

# getMergedCells function

src/worksheet/worksheet.ts:936

Read-only iterator over the worksheet's merged ranges.

function getMergedCells(ws: Worksheet): readonly CellRangeBoundaries[]

Parameters

NameTypeDescription
ws Worksheet

Returns

readonly CellRangeBoundaries[]

# getMergedRangeAt function

src/worksheet/worksheet.ts:953

Look up the merged range covering (row, col), or `undefined` if the coordinate isn't inside any merge. Lets callers introspect a merge without iterating `getMergedCells` themselves.

function getMergedRangeAt(ws: Worksheet, row: number, col: number): CellRangeBoundaries | undefined

Parameters

NameTypeDescription
ws Worksheet
row number
col number

Returns

CellRangeBoundaries | undefined

# getNonEmptyCellCount function

src/worksheet/worksheet.ts:645

Count non-empty cells. Distinct from countCells which counts every materialised cell (including ones whose `value === null`): this skips cells with a `null` value, plus optionally formulas / rich-text per the opts. Useful for "how many real values does this sheet contain" stats vs the materialised footprint.

function getNonEmptyCellCount(ws: Worksheet, opts?: { includeFormulas?: boolean; includeRichText?: boolean }): number

Parameters

NameTypeDescription
ws Worksheet
opts? = {}{ includeFormulas?: boolean; includeRichText?: boolean }

Returns

number

# getPopulatedColumnIndices function

src/worksheet/worksheet.ts:529

Sorted list of every column index that holds at least one populated cell anywhere on the sheet. Distinct columns only; returns `[]` for an empty worksheet.

function getPopulatedColumnIndices(ws: Worksheet): number[]

Parameters

NameTypeDescription
ws Worksheet

Returns

number[]

# getPopulatedRowIndices function

src/worksheet/worksheet.ts:516

Sorted list of every row index that holds at least one populated cell. Returns `[]` for an empty worksheet. Useful when a caller wants to iterate only the rows the user actually populated, without walking 1..maxRow in dense fashion.

function getPopulatedRowIndices(ws: Worksheet): number[]

Parameters

NameTypeDescription
ws Worksheet

Returns

number[]

# getRangeValues function

src/worksheet/worksheet.ts:1230

Read a rectangular range as a dense 2-D array of values. Empty cells yield `null`. The shape is `[maxRow - minRow + 1] × [maxCol - minCol + 1]`. Inverse of setRangeValues.

function getRangeValues(ws: Worksheet, range: string): CellValue[][]

Parameters

NameTypeDescription
ws Worksheet
range string

Returns

CellValue[][]

# getRowDimension function

src/worksheet/worksheet.ts:1831

Look up a row's dimension entry.

function getRowDimension(ws: Worksheet, row: number): RowDimension | undefined

Parameters

NameTypeDescription
ws Worksheet
row number

Returns

RowDimension | undefined

# getTable function

src/worksheet/worksheet.ts:2033

Look up a table by displayName.

function getTable(ws: Worksheet, displayName: string): TableDefinition | undefined

Parameters

NameTypeDescription
ws Worksheet
displayName string

Returns

TableDefinition | undefined

# groupColumns function

src/worksheet/worksheet.ts:1606

Mirror Excel's "Data → Group → Columns" by stamping every column in `[fromCol, toCol]` with an outline depth of `level` (default 1).

function groupColumns(ws: Worksheet, fromCol: number, toCol: number, level?: number): void

Parameters

NameTypeDescription
ws Worksheet
fromCol number
toCol number
level? = 1number

Returns

void

# groupRows function

src/worksheet/worksheet.ts:1574

Mirror Excel's "Data → Group → Rows" by stamping every row in `[fromRow, toRow]` with an outline depth of `level` (default 1). Allocates a RowDimension for each row that doesn't already have one. Ungroup with ungroupRows.

function groupRows(ws: Worksheet, fromRow: number, toRow: number, level?: number): void

Parameters

NameTypeDescription
ws Worksheet
fromRow number
toRow number
level? = 1number

Returns

void

# hideColumn function

src/worksheet/worksheet.ts:1491

Convenience: hide a column.

function hideColumn(ws: Worksheet, col: number): ColumnDimension

Parameters

NameTypeDescription
ws Worksheet
col number

Returns

ColumnDimension

# hideColumns function

src/worksheet/worksheet.ts:1514

Bulk-hide every column in `[fromCol, toCol]`.

function hideColumns(ws: Worksheet, fromCol: number, toCol: number): void

Parameters

NameTypeDescription
ws Worksheet
fromCol number
toCol number

Returns

void

# hideRow function

src/worksheet/worksheet.ts:1875

Convenience: hide a row.

function hideRow(ws: Worksheet, row: number): RowDimension

Parameters

NameTypeDescription
ws Worksheet
row number

Returns

RowDimension

# hideRows function

src/worksheet/worksheet.ts:1893

Bulk-hide every row in `[fromRow, toRow]`.

function hideRows(ws: Worksheet, fromRow: number, toRow: number): void

Parameters

NameTypeDescription
ws Worksheet
fromRow number
toRow number

Returns

void

# isWorksheetEmpty function

src/worksheet/worksheet.ts:630

True iff the worksheet has zero non-empty cells. Equivalent to `getNonEmptyCellCount(ws) === 0` but short-circuits on the first non-null value found, so the cost is O(first non-empty cell) rather than O(populated cells).

function isWorksheetEmpty(ws: Worksheet): boolean

Parameters

NameTypeDescription
ws Worksheet

Returns

boolean

# iterCells function

src/worksheet/worksheet.ts:486

Yield every populated cell in the worksheet as a flat stream (row-major, columns ascending). Distinct from iterRows which yields one row per row in the bounding box — use this when the caller wants only the populated cells without row boundaries or rectangular padding.

function iterCells(ws: Worksheet, opts?: IterRowsOptions): IterableIterator<Cell>

Parameters

NameTypeDescription
ws Worksheet
opts? = {}IterRowsOptions

Returns

IterableIterator<Cell>

# iterRows function

src/worksheet/worksheet.ts:450

Iterate the worksheet rows rectangularly. Yields one row per row in `[minRow, maxRow]` — including entirely empty rows — and each yielded row has length `maxCol - minCol + 1`. Missing cell positions are `undefined` (no placeholder Cell allocations). Defaults: `minRow=1`, `maxRow=getMaxRow(ws)`, `minCol=1`, `maxCol=getMaxCol(ws)`. The default extent is the populated bounding box, not the 1M × 16K sheet limit, so the rectangular default doesn't iterate the whole grid for a small sheet. To iterate populated rows only, filter: `[...iterRows(ws)].filter(row => row.some((c) => c !== undefined))`. To iterate populated cells without row boundaries, use iterCells.

function iterRows(ws: Worksheet, opts?: IterRowsOptions): IterableIterator<(Cell | undefined)[]>

Parameters

NameTypeDescription
ws Worksheet
opts? = {}IterRowsOptions

Returns

IterableIterator<(Cell | undefined)[]>

# iterValues function

src/worksheet/worksheet.ts:474

Same rectangular iteration as iterRows, but yields each cell's `.value`. Missing cell positions become `null` — already the canonical empty marker in `CellValue`.

function iterValues(ws: Worksheet, opts?: IterRowsOptions): IterableIterator<CellValue[]>

Parameters

NameTypeDescription
ws Worksheet
opts? = {}IterRowsOptions

Returns

IterableIterator<CellValue[]>

# listComments function

src/worksheet/worksheet.ts:2080

Read-only snapshot of every legacy comment on the sheet.

function listComments(ws: Worksheet): readonly LegacyComment[]

Parameters

NameTypeDescription
ws Worksheet

Returns

readonly LegacyComment[]

# listDataValidations function

src/worksheet/worksheet.ts:1997

Read-only snapshot of every data validation block on the sheet.

function listDataValidations(ws: Worksheet): readonly DataValidation[]

Parameters

NameTypeDescription
ws Worksheet

Returns

readonly DataValidation[]

# listTables function

src/worksheet/worksheet.ts:2038

Read-only snapshot of every Excel table defined on the sheet.

function listTables(ws: Worksheet): readonly TableDefinition[]

Parameters

NameTypeDescription
ws Worksheet

Returns

readonly TableDefinition[]

# makeWorksheet function

src/worksheet/worksheet.ts:239

Build a Worksheet shell.

function makeWorksheet(title: string): Worksheet

Parameters

NameTypeDescription
title string

Returns

Worksheet

# mergeCells function

src/worksheet/worksheet.ts:903

Merge a range. The top-left cell keeps its value; every other cell in the range is dropped from `ws.rows` so the on-wire `<sheetData>` won't carry phantom cells underneath the merge. Mirrors openpyxl's `MergedCellRange.format()`. Idempotent for an identical range, throws when the range overlaps an existing merge.

function mergeCells(ws: Worksheet, refOrRange: string | CellRangeBoundaries): CellRangeBoundaries

Parameters

NameTypeDescription
ws Worksheet
refOrRange string | CellRangeBoundaries

Returns

CellRangeBoundaries

# moveRange function

src/worksheet/worksheet.ts:1307

Move every populated cell from `source` to `target`. Equivalent to `copyRange` followed by clearing the source. When the ranges overlap on the same sheet, the copy walks in the direction that preserves data — high-to-low along any axis where the move shifts forward, low-to-high otherwise — so cells aren't overwritten before they've been read. Returns the number of cells moved.

function moveRange(ws: Worksheet, source: string, target: string, opts?: { targetWs?: Worksheet }): number

Parameters

NameTypeDescription
ws Worksheet
source string
target string
opts? = {}{ targetWs?: Worksheet }

Returns

number

# removeAllComments function

src/worksheet/worksheet.ts:2085

Drop every legacy comment on the worksheet. Returns the count removed.

function removeAllComments(ws: Worksheet): number

Parameters

NameTypeDescription
ws Worksheet

Returns

number

# removeAllConditionalFormatting function

src/worksheet/worksheet.ts:2154

Drop every conditional-formatting block on the worksheet. Returns the count removed.

function removeAllConditionalFormatting(ws: Worksheet): number

Parameters

NameTypeDescription
ws Worksheet

Returns

number

# removeAllDataValidations function

src/worksheet/worksheet.ts:2002

Drop every data validation block on the worksheet. Returns the count removed.

function removeAllDataValidations(ws: Worksheet): number

Parameters

NameTypeDescription
ws Worksheet

Returns

number

# removeAllMergedRanges function

src/worksheet/worksheet.ts:981

Drop every merged range on the worksheet. Returns the count of merges removed. Cells that were inside the merges keep their values — only the merge metadata is gone.

function removeAllMergedRanges(ws: Worksheet): number

Parameters

NameTypeDescription
ws Worksheet

Returns

number

# removeAllTables function

src/worksheet/worksheet.ts:2051

Drop every Excel table on the worksheet. Returns the count removed.

function removeAllTables(ws: Worksheet): number

Parameters

NameTypeDescription
ws Worksheet

Returns

number

# removeCellWatches function

src/worksheet/worksheet.ts:2169

Remove cell watches matching `predicate`. Returns the count removed.

function removeCellWatches(ws: Worksheet, predicate: (w: CellWatch) => boolean): number

Parameters

NameTypeDescription
ws Worksheet
predicate (w: CellWatch) => boolean

Returns

number

# removeDataValidations function

src/worksheet/worksheet.ts:1990

Drop every validation whose sqref overlaps `ref` (string parse). Returns count removed.

function removeDataValidations(ws: Worksheet, predicate: (dv: DataValidation) => boolean): number

Parameters

NameTypeDescription
ws Worksheet
predicate (dv: DataValidation) => boolean

Returns

number

# removeIgnoredErrors function

src/worksheet/worksheet.ts:2182

Remove ignored-error entries matching `predicate`. Returns the count removed.

function removeIgnoredErrors(ws: Worksheet, predicate: (ie: IgnoredError) => boolean): number

Parameters

NameTypeDescription
ws Worksheet
predicate (ie: IgnoredError) => boolean

Returns

number

# removeTable function

src/worksheet/worksheet.ts:2043

Drop a table by displayName. Returns true when something was removed.

function removeTable(ws: Worksheet, displayName: string): boolean

Parameters

NameTypeDescription
ws Worksheet
displayName string

Returns

boolean

# setAutoFilter function

src/worksheet/worksheet.ts:2011

Set or replace the worksheet's AutoFilter. Pass `undefined` to clear.

function setAutoFilter(ws: Worksheet, filter: AutoFilter | undefined): void

Parameters

NameTypeDescription
ws Worksheet
filter AutoFilter | undefined

Returns

void

# setCell function

src/worksheet/worksheet.ts:288

Create or update a Cell at (row, col). Existing cells keep their styleId / hyperlinkId / commentId unless explicitly overridden.

function setCell(ws: Worksheet, row: number, col: number, value?: CellValue, styleId?: number): Cell

Parameters

NameTypeDescription
ws Worksheet
row number
col number
value? = nullCellValue
styleId? number

Returns

Cell

# setCellByCoord function

src/worksheet/worksheet.ts:872

Resolve an "A1" coordinate to a numeric (col, row) pair on the sheet.

function setCellByCoord(ws: Worksheet, coord: string, value?: CellValue, styleId?: number): Cell

Parameters

NameTypeDescription
ws Worksheet
coord string
value? CellValue
styleId? number

Returns

Cell

# setColumnDimension function

src/worksheet/worksheet.ts:1468

Set a single-column ColumnDimension entry covering `col`. Shadows any existing run that overlaps — runs are not split for now (callers that need range-spanning entries can write directly into `ws.columnDimensions`).

function setColumnDimension(ws: Worksheet, col: number, opts: Partial<Omit<ColumnDimension, "min" | "max">>): ColumnDimension

Parameters

NameTypeDescription
ws Worksheet
col number
opts Partial<Omit<ColumnDimension, "min" | "max">>

Returns

ColumnDimension

# setColumnWidth function

src/worksheet/worksheet.ts:1485

Convenience: set a column's width, leaving other fields untouched.

function setColumnWidth(ws: Worksheet, col: number, width: number): ColumnDimension

Parameters

NameTypeDescription
ws Worksheet
col number
width number

Returns

ColumnDimension

# setColumnWidths function

src/worksheet/worksheet.ts:1809

Set widths for many columns in one call. `widths` maps either: - an array `[12, 16, 20]` interpreted positionally starting at column `startCol` (default 1), or - a `Record<number, number>` keyed by 1-based column index. Each entry sets `customWidth: true`.

function setColumnWidths(ws: Worksheet, widths: readonly number[] | Record<number, number>, startCol?: number): void

Parameters

NameTypeDescription
ws Worksheet
widths readonly number[] | Record<number, number>
startCol? = 1number

Returns

void

# setComment function

src/worksheet/worksheet.ts:2060

Add or replace the comment at `ref`.

function setComment(ws: Worksheet, opts: { author: string; ref: string; text: string }): LegacyComment

Parameters

NameTypeDescription
ws Worksheet
opts { author: string; ref: string; text: string }

Returns

LegacyComment

# setDefaultColumnWidth function

src/worksheet/worksheet.ts:1534

Set the default column width (characters) for cells without an explicit ColumnDimension entry. Mirrors Excel's "Default Width" dialog. Pass `undefined` to clear.

function setDefaultColumnWidth(ws: Worksheet, width: number | undefined): void

Parameters

NameTypeDescription
ws Worksheet
width number | undefined

Returns

void

# setDefaultRowHeight function

src/worksheet/worksheet.ts:1550

Set the default row height (points) for rows without an explicit RowDimension entry. Mirrors Excel's "Default Row Height" dialog. Pass `undefined` to clear.

function setDefaultRowHeight(ws: Worksheet, height: number | undefined): void

Parameters

NameTypeDescription
ws Worksheet
height number | undefined

Returns

void

# setFreezePanes function

src/worksheet/worksheet.ts:1004

Freeze rows / columns above + left of `topLeftRef` ("B2" → 1 row + 1 col). Pass `undefined` to clear any existing freeze. Targets the workbook's primary SheetView (`ws.views[0]`); creates one if absent.

function setFreezePanes(ws: Worksheet, topLeftRef: string | undefined): void

Parameters

NameTypeDescription
ws Worksheet
topLeftRef string | undefined

Returns

void

# setRangeValues function

src/worksheet/worksheet.ts:1189

Set values across a rectangular range from a 2-D array. `rows[0]` is laid down starting at the top-left of `range`; subsequent rows follow. `null` / `undefined` entries skip the cell. Useful for dropping a header + data block in one call.

function setRangeValues(ws: Worksheet, range: string, rows: readonly readonly (CellValue | undefined)[][]): void

Parameters

NameTypeDescription
ws Worksheet
range string
rows readonly readonly (CellValue | undefined)[][]

Returns

void

# setRowDimension function

src/worksheet/worksheet.ts:1835
function setRowDimension(ws: Worksheet, row: number, opts: Partial<RowDimension>): RowDimension

Parameters

NameTypeDescription
ws Worksheet
row number
opts Partial<RowDimension>

Returns

RowDimension

# setRowHeight function

src/worksheet/worksheet.ts:1843

Convenience: set a row's height, marking customHeight=true.

function setRowHeight(ws: Worksheet, row: number, height: number): RowDimension

Parameters

NameTypeDescription
ws Worksheet
row number
height number

Returns

RowDimension

# setRowHeights function

src/worksheet/worksheet.ts:1853

Set heights for many rows in one call. `heights` accepts an array (positional from `startRow`, default 1) or a `Record<number, number>` keyed by 1-based row index. Each entry sets `customHeight: true`.

function setRowHeights(ws: Worksheet, heights: readonly number[] | Record<number, number>, startRow?: number): void

Parameters

NameTypeDescription
ws Worksheet
heights readonly number[] | Record<number, number>
startRow? = 1number

Returns

void

# setSheetTabColor function

src/worksheet/worksheet.ts:1094

Set the sheet tab strip colour. Accepts either a hex string (`"FF0070C0"`) or a partial `Color` object (`{ theme: 4, tint: 0.4 }`).

function setSheetTabColor(ws: Worksheet, color: string | Partial<Color>): Color

Parameters

NameTypeDescription
ws Worksheet
color string | Partial<Color>

Returns

Color

# setSheetViewMode function

src/worksheet/worksheet.ts:1143

Switch the sheet view between Excel's "Normal" / "Page Break Preview" / "Page Layout" modes.

function setSheetViewMode(ws: Worksheet, mode: "normal" | "pageBreakPreview" | "pageLayout"): void

Parameters

NameTypeDescription
ws Worksheet
mode "normal" | "pageBreakPreview" | "pageLayout"

Returns

void

# setSheetZoom function

src/worksheet/worksheet.ts:1135

Set the zoom scale (percent) on the primary SheetView. Excel accepts integer percentages in `[10, 400]`.

function setSheetZoom(ws: Worksheet, scale: number): void

Parameters

NameTypeDescription
ws Worksheet
scale number

Returns

void

# ungroupColumns function

src/worksheet/worksheet.ts:1621

Drop the outline grouping for every column in `[fromCol, toCol]`. Removes the `outlineLevel` field from each affected ColumnDimension.

function ungroupColumns(ws: Worksheet, fromCol: number, toCol: number): void

Parameters

NameTypeDescription
ws Worksheet
fromCol number
toCol number

Returns

void

# ungroupRows function

src/worksheet/worksheet.ts:1589

Drop the outline grouping for every row in `[fromRow, toRow]`. Removes the `outlineLevel` field from each affected RowDimension.

function ungroupRows(ws: Worksheet, fromRow: number, toRow: number): void

Parameters

NameTypeDescription
ws Worksheet
fromRow number
toRow number

Returns

void

# unhideColumn function

src/worksheet/worksheet.ts:1501

Convenience: unhide a column. Drops the `hidden` flag from the column's dimension entry (and removes the entry altogether when no other fields remain).

function unhideColumn(ws: Worksheet, col: number): void

Parameters

NameTypeDescription
ws Worksheet
col number

Returns

void

# unhideColumns function

src/worksheet/worksheet.ts:1522

Bulk-unhide every column in `[fromCol, toCol]`.

function unhideColumns(ws: Worksheet, fromCol: number, toCol: number): void

Parameters

NameTypeDescription
ws Worksheet
fromCol number
toCol number

Returns

void

# unhideRow function

src/worksheet/worksheet.ts:1884

Convenience: unhide a row. Drops the `hidden` flag from the row's dimension entry (and removes the entry altogether when no other fields remain).

function unhideRow(ws: Worksheet, row: number): void

Parameters

NameTypeDescription
ws Worksheet
row number

Returns

void

# unhideRows function

src/worksheet/worksheet.ts:1901

Bulk-unhide every row in `[fromRow, toRow]`.

function unhideRows(ws: Worksheet, fromRow: number, toRow: number): void

Parameters

NameTypeDescription
ws Worksheet
fromRow number
toRow number

Returns

void

# unmergeCells function

src/worksheet/worksheet.ts:927

Drop a previously-merged range. No-op if the range isn't registered.

function unmergeCells(ws: Worksheet, refOrRange: string | CellRangeBoundaries): boolean

Parameters

NameTypeDescription
ws Worksheet
refOrRange string | CellRangeBoundaries

Returns

boolean

# unmergeCellsAt function

src/worksheet/worksheet.ts:965

Drop the merge that contains (row, col), if any. Returns `true` when a merge was unregistered. Useful when callers know a cell coordinate but not the original merge bounds.

function unmergeCellsAt(ws: Worksheet, row: number, col: number): boolean

Parameters

NameTypeDescription
ws Worksheet
row number
col number

Returns

boolean

# writeRange function

src/worksheet/worksheet.ts:403

Write a 2D array of values to the sheet starting at the given A1 anchor cell. Distinct from appendRows (which always writes past `_appendRowCursor`) — this lets you place a block at an arbitrary location, e.g. mid-sheet table updates. `null` / `undefined` entries leave the corresponding cell **untouched** (existing cell + style are preserved). Pre-existing cells inside the written rectangle are overwritten in place, so their `styleId` survives the write. Returns the bounding-box of the written area as 1-based inclusive coordinates. An empty rows array returns `undefined` rather than an invalid zero-area range.

function writeRange(ws: Worksheet, startRef: string, values: readonly readonly (CellValue | undefined)[][]): { maxCol: number; maxRow: number; minCol: number; minRow: number } | undefined

Parameters

NameTypeDescription
ws Worksheet
startRef string
values readonly readonly (CellValue | undefined)[][]

Returns

{ maxCol: number; maxRow: number; minCol: number; minRow: number } | undefined

Page setup

src/worksheet/page-setup.ts

# buildHeaderFooterText function

src/worksheet/page-setup.ts:221

Build a header / footer string from optional left / center / right fragments using Excel's `&L` / `&C` / `&R` markers. An empty fragment is omitted (no marker emitted) so a center-only header doesn't leave a stray `&L` prefix. Returns `''` when all three fragments are undefined.

function buildHeaderFooterText(parts: { center?: string; left?: string; right?: string }): string

Parameters

NameTypeDescription
parts { center?: string; left?: string; right?: string }

Returns

string

# makeHeaderFooter function

src/worksheet/page-setup.ts:95
function makeHeaderFooter(opts?: HeaderFooter): HeaderFooter

Parameters

NameTypeDescription
opts? = {}HeaderFooter

Returns

HeaderFooter

# makePageBreak function

src/worksheet/page-setup.ts:111
function makePageBreak(opts?: PageBreak): PageBreak

Parameters

NameTypeDescription
opts? = {}PageBreak

Returns

PageBreak

# makePageMargins function

src/worksheet/page-setup.ts:82
function makePageMargins(opts?: Partial<PageMargins>): PageMargins

Parameters

NameTypeDescription
opts? = {}Partial<PageMargins>

Returns

PageMargins

# makePageSetup function

src/worksheet/page-setup.ts:93
function makePageSetup(opts?: PageSetup): PageSetup

Parameters

NameTypeDescription
opts? = {}PageSetup

Returns

PageSetup

# makePrintOptions function

src/worksheet/page-setup.ts:91
function makePrintOptions(opts?: PrintOptions): PrintOptions

Parameters

NameTypeDescription
opts? = {}PrintOptions

Returns

PrintOptions

Scenarios

src/worksheet/scenarios.ts

# makeScenario function

src/worksheet/scenarios.ts:50
function makeScenario(opts: Scenario): Scenario

Parameters

NameTypeDescription
opts Scenario

Returns

Scenario

# makeScenarioInputCell function

src/worksheet/scenarios.ts:42
function makeScenarioInputCell(opts: ScenarioInputCell): ScenarioInputCell

Parameters

NameTypeDescription
opts ScenarioInputCell

Returns

ScenarioInputCell

# makeScenarioList function

src/worksheet/scenarios.ts:59
function makeScenarioList(opts?: Partial<ScenarioList>): ScenarioList

Parameters

NameTypeDescription
opts? = {}Partial<ScenarioList>

Returns

ScenarioList

Smart tags

src/worksheet/smart-tags.ts

# makeCellSmartTag function

src/worksheet/smart-tags.ts:36
function makeCellSmartTag(opts: Partial<CellSmartTag> & { type: number }): CellSmartTag

Parameters

NameTypeDescription
opts Partial<CellSmartTag> & { type: number }

Returns

CellSmartTag

# makeCellSmartTagProperty function

src/worksheet/smart-tags.ts:34
function makeCellSmartTagProperty(key: string, val: string): CellSmartTagProperty

Parameters

NameTypeDescription
key string
val string

Returns

CellSmartTagProperty

# makeCellSmartTags function

src/worksheet/smart-tags.ts:43
function makeCellSmartTags(opts: Partial<CellSmartTags> & { ref: string }): CellSmartTags

Parameters

NameTypeDescription
opts Partial<CellSmartTags> & { ref: string }

Returns

CellSmartTags

Views

src/worksheet/views.ts

# freezePaneRef function

src/worksheet/views.ts:100

Inverse of makeFreezePane. Returns the top-left ref of the bottomRight pane, or undefined.

function freezePaneRef(view: SheetView): string | undefined

Parameters

NameTypeDescription
view SheetView

Returns

string | undefined

# makeFreezePane function

src/worksheet/views.ts:78

Build a frozen Pane from a top-left coordinate. Per Excel semantics: - "B2" → freeze 1 row + 1 col → xSplit=1, ySplit=1, activePane='bottomRight' - "A2" → freeze 1 row only → ySplit=1, activePane='bottomLeft' - "B1" → freeze 1 col only → xSplit=1, activePane='topRight' - "A1" → no freeze; throws (caller should clear `ws.views[].pane`).

function makeFreezePane(topLeftRef: string): Pane

Parameters

NameTypeDescription
topLeftRef string

Returns

Pane

# makeSheetView function

src/worksheet/views.ts:53

Build a SheetView with sensible defaults.

function makeSheetView(opts?: Partial<SheetView>): SheetView

Parameters

NameTypeDescription
opts? = {}Partial<SheetView>

Returns

SheetView

Dimensions

src/worksheet/dimensions.ts

# makeColumnDimension function

src/worksheet/dimensions.ts:50

Build a single-column ColumnDimension entry covering `col`.

function makeColumnDimension(col: number, opts?: Partial<Omit<ColumnDimension, "min" | "max">>): ColumnDimension

Parameters

NameTypeDescription
col number
opts? = {}Partial<Omit<ColumnDimension, "min" | "max">>

Returns

ColumnDimension

# makeRowDimension function

src/worksheet/dimensions.ts:67
function makeRowDimension(opts?: Partial<RowDimension>): RowDimension

Parameters

NameTypeDescription
opts? = {}Partial<RowDimension>

Returns

RowDimension

Errors

src/worksheet/errors.ts

# makeCellWatch function

src/worksheet/errors.ts:52
function makeCellWatch(ref: string): CellWatch

Parameters

NameTypeDescription
ref string

Returns

CellWatch

# makeIgnoredError function

src/worksheet/errors.ts:54
function makeIgnoredError(opts: Partial<IgnoredError> & { sqref: MultiCellRange }): IgnoredError

Parameters

NameTypeDescription
opts Partial<IgnoredError> & { sqref: MultiCellRange }

Returns

IgnoredError

Ole objects

src/worksheet/ole-objects.ts

# makeFormControl function

src/worksheet/ole-objects.ts:57
function makeFormControl(opts: Partial<FormControl> & { shapeId: number }): FormControl

Parameters

NameTypeDescription
opts Partial<FormControl> & { shapeId: number }

Returns

FormControl

# makeOleObject function

src/worksheet/ole-objects.ts:46
function makeOleObject(opts: Partial<OleObject> & { shapeId: number }): OleObject

Parameters

NameTypeDescription
opts Partial<OleObject> & { shapeId: number }

Returns

OleObject

Sort state

src/worksheet/sort-state.ts

# makeSortCondition function

src/worksheet/sort-state.ts:51
function makeSortCondition(opts: SortCondition): SortCondition

Parameters

NameTypeDescription
opts SortCondition

Returns

SortCondition

# makeSortState function

src/worksheet/sort-state.ts:53
function makeSortState(opts: Partial<SortState> & { ref: string }): SortState

Parameters

NameTypeDescription
opts Partial<SortState> & { ref: string }

Returns

SortState

Web publish

src/worksheet/web-publish.ts

# makeWebPublishItem function

src/worksheet/web-publish.ts:37
function makeWebPublishItem(opts: WebPublishItem): WebPublishItem

Parameters

NameTypeDescription
opts WebPublishItem

Returns

WebPublishItem

# makeWorksheetCustomProperty function

src/worksheet/web-publish.ts:30
function makeWorksheetCustomProperty(opts: WorksheetCustomProperty): WorksheetCustomProperty

Parameters

NameTypeDescription
opts WorksheetCustomProperty

Returns

WorksheetCustomProperty

Custom sheet views

src/worksheet/custom-sheet-views.ts

# makeCustomSheetView function

src/worksheet/custom-sheet-views.ts:52
function makeCustomSheetView(opts: Partial<CustomSheetView> & { guid: string }): CustomSheetView

Parameters

NameTypeDescription
opts Partial<CustomSheetView> & { guid: string }

Returns

CustomSheetView

Data consolidate

src/worksheet/data-consolidate.ts

# makeDataConsolidate function

src/worksheet/data-consolidate.ts:47
function makeDataConsolidate(opts?: DataConsolidate): DataConsolidate

Parameters

NameTypeDescription
opts? = {}DataConsolidate

Returns

DataConsolidate

Phonetic

src/worksheet/phonetic.ts

# makeWorksheetPhoneticProperties function

src/worksheet/phonetic.ts:21
function makeWorksheetPhoneticProperties(opts?: WorksheetPhoneticProperties): WorksheetPhoneticProperties

Parameters

NameTypeDescription
opts? = {}WorksheetPhoneticProperties

Returns

WorksheetPhoneticProperties

Properties

src/worksheet/properties.ts

# makeSheetProperties function

src/worksheet/properties.ts:47
function makeSheetProperties(opts?: SheetProperties): SheetProperties

Parameters

NameTypeDescription
opts? = {}SheetProperties

Returns

SheetProperties

Protected ranges

src/worksheet/protected-ranges.ts

# makeProtectedRange function

src/worksheet/protected-ranges.ts:26
function makeProtectedRange(opts: Partial<ProtectedRange> & { name: string; sqref: MultiCellRange }): ProtectedRange

Parameters

NameTypeDescription
opts Partial<ProtectedRange> & { name: string; sqref: MultiCellRange }

Returns

ProtectedRange

Protection

src/worksheet/protection.ts

# makeSheetProtection function

src/worksheet/protection.ts:43
function makeSheetProtection(opts?: SheetProtection): SheetProtection

Parameters

NameTypeDescription
opts? = {}SheetProtection

Returns

SheetProtection