Skip to content

Cell

Represents a single cell with value, metadata, and optional format.

ts
import { Cell } from "betterspread"

Constructor

ts
new Cell(opts: CellOptions)

CellOptions

PropertyTypeDefaultDescription
valuestringCell value
label?string"A"Column label
rowIndex?number1Row number
cellIndex?number0Column index
tab?TabInstanceParent Tab
row?RowInstance | nullnullParent Row
format?CellFormat | FormatCell formatting

Properties

PropertyTypeDescription
valuestring (readonly)Cell value
labelstring (readonly)Column label (e.g. "B")
rowIndexnumber (readonly)Row number
cellIndexnumber (readonly)Column index (0-based)
tabTabInstance | undefined (readonly)Parent Tab
rowRowInstance | null (readonly)Parent Row
formatFormat | nullCell format
headerstring (getter)Column header from Tab cache

Methods

update()

ts
update(opts: CellUpdateOpts): Promise<this>

Updates cell value and optional format. Returns this for chaining.

CellUpdateOpts

PropertyTypeDescription
valuestringNew value
format?FormatOptional cell format
inputFormat?ValueInputOption"RAW" (default) or "USER_ENTERED"

clear()

ts
clear(): Promise<void>

Clears the cell value.

style()

ts
style(style: Format): Promise<void>

Applies a Format to this cell.

delete()

ts
delete(shift: "left" | "up" = "left"): Promise<void>

Deletes the cell, shifting remaining cells left or up.

toString()

ts
toString(): string

Returns cell value. Called implicitly on string coercion.

toJSON()

ts
toJSON(): string

Returns cell value for JSON serialization.