Skip to content

WorkSheet

An object describing a sheet of A1-addressable spreadsheet cells.

  • emitter

new WorkSheet(name, workbookKey, index, styles, hidden, workbookType): WorkSheet

string

number

number

StyleManager

0 | 1 | 2

The origin of the workbook (Excel, Google Sheets, CSV, etc).

"unknown" | "airtable" | "notion" | "smartsheet" | "csv" | "excel" | "form-submissions" | "google-sheets" | "native"

WorkSheet

EventEmitter.constructor

_cells: Cells


columns: GridSize[]


colWidths: Record<string, number>


defaults: object

optional colWidth: number

optional rowHeight: number


drawings: DrawingCSF[]


hidden: 0 | 1 | 2


index: number


locallyScopedNames: Record<string, DefinedName> = {}


merged_cells: string[]


merges: Record<string, [number, number]>


name: string


rowHeights: Record<number, number>


rows: GridSize[]


showGridLines: boolean = true


optional views: WorksheetView[]


workbookKey: number

get cellCount(): number

number


get tableName(): null | string

null | string

_convertToStructuredSheet(table): void

Table

void


_setRowHeight(rowNum, height): boolean

number

0-based row index

number

non-negative

boolean

true if visibility changed (the row height was previously 0 and now isn’t, or vice versa)

if rowNum is not present in the sheet, or if height is a negative number


_splitUpOverlappingRangeWrites(ref): undefined | Cell

Look for range write nodes in the R-Tree that overlap with the given range, and if there are any, split them up such that the remaining set of range write nodes cover any cells previously covered, but do not overlap the given range. If the given range is a single-cell address, and there exists a formula cell at that address (which will have been neutralized by one of the overlapping range writes), then reinstate the cell R-tree node for that cell (else it would not be covered by any R-tree cell).

SlimRange

undefined | Cell

the cell whose neutralized formula was reinstated, if any


_updateColumnMetadata(column, wasInserted, count): void

Adjust the columns attribute after insertion/deletion of one or more columns

number

0-based column index of the first inserted/deleted column

boolean

true if inserted, false if deleted

number = 1

number of affected columns

void

if column is negative or not an integer, or if count is less than 1 or not an integer


_updateParsedFormula(cell, ctx?, validateNow?): void

Precondition: formula parser has finished importing (formulaParserReady has resolved). NOTE: this function does not assert this precondition; callers must do so.

CellItem

EvaluationContext

boolean = true

void


_writeCellData(cellLocation, cellData, ctx?): object

Write the given cell data attributes (.v, .f, etc.) to an existing or new cell at the given ID. NOTE: clients should update cells using Workbook.writeCellData; this should be called only from Workbook. If cell value is an error value, normalize it to the corresponding the singleton error value in errorTable. If the cell has a formula, it is parsed and (if parsing succeeds) the AST is stored in the cell object. Precondition: formula parser has finished importing (formulaParserReady has resolved).

zero-based sheet coordinates of cell to write

number

number

CellData

object with attributes to write to the cell

EvaluationContext

evaluation context (for looking up lambdas in formula, to not misreport calls to unsupported functions)

object

the existing or new cell, and any other ranges which may have been affected by masking/unmasking

cell: Cell

changedRanges: Range[]

if precondition is not satisfied (the formula parser has not finished importing)


clearCellsByRange(range): (CellVertexId | RangeVertexId)[]

Range

(CellVertexId | RangeVertexId)[]

The places that got changed. This can include cells outside of range, which may have been changed in ways other than clearing them, because of spill ranges getting unblocked by the clearing of range.


emit(event, …arguments_): Emitter

Emit an event, invoking all handlers registered for it.

string

The name of the event to emit.

any[]

Arguments to pass to the event handlers.

Emitter

The Emitter instance for method chaining.

EventEmitter.emit


getBounds(): SlimRange

SlimRange


getCell(cellID): null | Cell

string

null | Cell


getCellByCoords(row, col, willEdit, formulaCell): null | Cell

number

number

boolean = false

boolean = false

null | Cell


getCellByID(cellID): null | Cell

string

cell address in A1 form without prefix

null | Cell


getCellByRange(range): null | Cell

number

number

null | Cell


getCells(includeStyleOnly?): IterableIterator<Cell>

Returns an iterator of all cells contained in this sheet, even individual cells within spilled ranges.

boolean = false

include cells that have never had a value but only style info

IterableIterator<Cell>


getColumns(): object[]

object[]


getDataCellByCoords(row, col): null | Cell

number

number

null | Cell


getSize(): [number, number]

[number, number]


getSpillAnchoredAtRange(range): null | Range

Get the area which a spilled range covers, given a reference to the spilled range’s anchor cell.

Range | Reference

null | Range


hasListeners(event): boolean

Check if there are any handlers registered for a specific event.

string

The name of the event.

boolean

true if there are one or more handlers, false otherwise.

EventEmitter.hasListeners

hasListeners(): boolean

Check if there are any handlers registered for any event.

boolean

true if there are one or more handlers for any event, false otherwise.

EventEmitter.hasListeners


isStructuredSheet(): boolean

boolean


iterAnchorCellsInRange(range): IterableIterator<Cell>

Iterate all cells in range, except spilled cells

SlimRange

IterableIterator<Cell>


iterFormulaCells(): IterableIterator<Cell>

Yield all formula cells.

IterableIterator<Cell>


iterValueCellsInColumn(columnIndex, maxRow): Generator<Cell, void, unknown>

number

number = Infinity

Generator<Cell, void, unknown>


listenerCount(event): number

Get the count of listeners for a specific event.

string

The name of the event.

number

The number of listeners for the event.

EventEmitter.listenerCount

listenerCount(): number

Get the count of all event handlers in total.

number

The total number of event handlers.

EventEmitter.listenerCount


listeners(event): (…arguments_) => void[]

Retrieve the event handlers registered for a specific event.

string

The name of the event.

(…arguments_) => void[]

An array of functions registered as handlers for the event.

EventEmitter.listeners


makeCell(cellLocation): Cell

number

number

Cell


moveCells(otherSheet, from, to): object

WorkSheet

Range

Range

object

changedRefsInFrom: Reference[]

changedRefsInTo: Reference[]


nextBoundaryByCoords(row, col, direction): null | { further: { cell: null; col: number; id: string; row: number; }; nearer: { cell: Cell; col: number; id: string; row: number; }; } | { further: { cell: Cell; col: number; id: string; row: number; }; nearer: { cell: null; col: number; id: string; row: number; }; }

Find the next boundary between an empty and non empty cell in the given direction relative to (row, col).

number

number

string

Direction relative to (row, col) to search in; can be ‘left’, ‘right’, ‘up’, ‘down’, or case variations of those.

null | { further: { cell: null; col: number; id: string; row: number; }; nearer: { cell: Cell; col: number; id: string; row: number; }; } | { further: { cell: Cell; col: number; id: string; row: number; }; nearer: { cell: null; col: number; id: string; row: number; }; }


nextBoundaryByID(cellAddr, direction): null | { further: { cell: null; col: number; id: string; row: number; }; nearer: { cell: Cell; col: number; id: string; row: number; }; } | { further: { cell: Cell; col: number; id: string; row: number; }; nearer: { cell: null; col: number; id: string; row: number; }; }

Find the next boundary between an empty and non empty cell in the given direction relative to the given cell.

string

Cell which search is relative to

string

Direction relative to cellAddr to search in; can be ‘left’, ‘right’, ‘up’, ‘down’, or case variations of those.

null | { further: { cell: null; col: number; id: string; row: number; }; nearer: { cell: Cell; col: number; id: string; row: number; }; } | { further: { cell: Cell; col: number; id: string; row: number; }; nearer: { cell: null; col: number; id: string; row: number; }; }


nextValueCellByCoords(row, col, direction): null | Cell

Find the next non-blank cell in the given direction relative to (row, col). The search ignores the cell at exacly (row, col).

number

Row index

number

Column index

string

Direction relative to (row, col) to search in; can be ‘left’, ‘right’, ‘up’, ‘down’, or case variations of those.

null | Cell

Non-blank cell or null


nextValueCellByID(cellAddr, direction): null | Cell

Find the next non-blank cell in the given direction relative to the given cell. The search ignores the cell at cellAddr.

string

Cell which search is relative to

string

Direction relative to cellAddr to search in; can be ‘left’, ‘right’, ‘up’, ‘down’, or case variations of those.

null | Cell

Non-blank cell or null


off(event, listener): Emitter

Remove a specific event handler for a specified event.

string

The name of the event.

(…arguments_) => void

The specific handler function to remove.

Emitter

The Emitter instance for method chaining.

EventEmitter.off

off(event): Emitter

Remove all event handlers for a specified event.

string

The name of the event for which to remove all handlers.

Emitter

The Emitter instance for method chaining.

EventEmitter.off

off(): Emitter

Remove all event handlers for all events.

Emitter

The Emitter instance for method chaining.

EventEmitter.off


on(event, listener): Emitter

Register an event handler that listens to a specified event.

string

The name of the event to listen to.

(…arguments_) => void

The function to execute when the event is emitted.

Emitter

The Emitter instance for method chaining.

EventEmitter.on


once(event, listener): Emitter

Register a one-time event handler for a specified event.

string

The name of the event to listen to.

(…arguments_) => void

The function to execute once when the event is emitted.

Emitter

The Emitter instance for method chaining.

EventEmitter.once


prepareCellMerges(): void

void


reset(): void

void


resolveArea<O>(range, options): ResolveAreaResult<O>

O extends ResolveAreaOptions<Readonly<{ returnBoxed: boolean; returnCells: boolean; returnLambda: boolean; }>>

SlimRange

O = ...

ResolveAreaResult<O>


setColumnWidth(column, width): void

number

0-based column index

number

non-negative

void

if column or width is negative, or column is not an integer


setDataFromCSF(csfSheetData, ctx?, options?): Reference[]

Fast path for setting data from CSF format directly, bypassing JSF conversion. This provides significantly better performance when the source data is in CSF format.

CSFSheetWithJSFCells

Sheet data in CSF format

EvaluationContext

Evaluation context for formula parsing

PopulateOptions = {}

Population options (willRecalc, assumeArrayFormulas)

Reference[]

References to cells that need recalculation

The formula parser must be loaded before calling this method

if precondition is not satisfied (the formula parser has not finished importing)


setDataFromJSF(jsfSheetData, ctx?, jsfContext?, options?): Reference[]

Populate this sheet with data from JSF (native path).

Cells are expanded on-demand using workbook-level JSF context (formulas, styles, dateAdjust).

Precondition: formula parser has finished importing (formulaParserReady has resolved).

JSFWorksheetRelaxed

the JSF sheet data

EvaluationContext

context for looking up names (to not record calls to named lambdas as calls to unsupported functions)

workbook-level JSF context (provides formulas array, styles array, and dateAdjust for cell expansion)

number

string[]

StyleRelaxed[]

PopulateOptions = {}

populate options

Reference[]

if precondition is not satisfied (the formula parser has not finished importing)


setIndex(index): void

number

void


visitFormulaCellsIntersecting(range, callback): void

Visits all formula cells within the given range. Also includes formula cells that spill into the range.

SlimRange

CallbackWithStop<Cell>

void