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
columns: GridSize[];

colWidths: Record<string, number>;

comments: ThreadedComment[];

Threaded comments.

Top-level comments may have replies. Each top-level comment is linked to a single cell in the sheet. Comment bodies are plain text. Structured annotations such as @mentions and hyperlinks are expressed via the optional runs array, which references character ranges within the text.


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;

notes: Note[];

Cell notes.

Each note is linked to a single cell and contains plain text content.


rowHeights: Record<number, number>;

rows: GridSize[];

optional views: WorksheetView[];
get cellCount(): number;

number


get dataTableCells(): ReadonlySet<Cell>;

ReadonlySet<Cell>

_parseFormulasAndInferArrayType(
refsNeedingRecalc,
assumeArrayFormulas?,
ctx?): void;

Parse formulas and infer array type for all formula cells. Also collects HYPERLINK cells that need recalculation into the provided array.

Reference[]

boolean

EvaluationContext

void


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): Cell | null;

string

Cell | null


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

number

number

boolean = false

boolean = false

Cell | null


getCellByID(cellID): Cell | null;

string

cell address in A1 form without prefix

Cell | null


getCellByRange(range): Cell | null;

number

number

Cell | null


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>


getComments(options): ThreadedComment[];

Get threaded comments on this sheet with optional filtering.

FilterOptions = {}

ThreadedComment[]


getNotes(): Note[];

Gets the notes attached to cells within this worksheet.

Copies are returned to prevent external mutation of the sheet’s notes.

Note[]


getSize(): [number, number];

[number, number]


getSpillAnchoredAtRange(range): Range | null;

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

Range | Reference

Range | null


getViews(): WorksheetView[];

Gets the worksheet’s saved view configurations (selected cell, zoom, layout, etc).

Copies are returned to prevent external mutation of the sheet’s views.

WorksheetView[]


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

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

mergeCells(rangeStr): void;

Merge a range of cells. The range must span at least 2 cells and must not overlap any existing merge.

Existing values in non-anchor cells are discarded (cleared to empty). The anchor cell’s value is left as-is; no values are moved into it.

string

range in A1 notation, e.g. “A1:B2”

void

if the range is a single cell or overlaps an existing merge


nextBoundaryByCoords(
row,
col,
direction):
| {
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;
};
}
| null;

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.

| { 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; }; } | null


nextBoundaryByID(cellAddr, direction):
| {
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;
};
}
| null;

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.

| { 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; }; } | null


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

Find the next non-blank cell in the given direction relative to (row, col). The search ignores the cell at exactly (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.

Cell | null

Non-blank cell or null


nextValueCellByID(cellAddr, direction): Cell | null;

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.

Cell | null

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

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


unmergeCells(rangeStr): void;

Unmerge cells. Any existing merge that overlaps the given range is fully removed. If no merges overlap, this is a no-op.

string

range in A1 notation, e.g. “A1:B2”

void