Skip to content
TREB Docs

EmbeddedSpreadsheet

EmbeddedSpreadsheet class

embedded spreadsheet

Properties

active_sheetconvenience function returns the name of the active sheet.
can_revertthis flag indicates we can revert the document.
dirtyindicates the current revision of the document is not equal to the last-saved revision of the document.
document_namedocument name (metadata)
headlessheadless state
scalecurrent grid scale
sheet_namesreturns the names of all sheets in the current document
statestate is the current revision of the document.
user_dataopaque user data (metadata).

Methods

AboutShow the about dialog.
ActivateSheetActivate sheet.
AddSheetAdd a sheet, optionally named.
ApplyBordersApply borders to range.
ApplyStyleApply style to range.
BatchUse this function to batch multiple document changes.
CancelCancel subscription
ClearNameRemove a named range (removes the name, not the range).
DefineFunctionCreate a macro function.
DefineNameCreate a named range or named expression.
DeleteColumnsDelete columns(s).
DeleteRowsDelete row(s).
DeleteSheetDelete a sheet.
EvaluateEvaluate an arbitrary expression in the spreadsheet.
ExportExport to XLSX file.
ExportDelimitedExport sheet as CSV/TSV.
ExternalEditorset or remove an external editor.
FilterTablefilter a table.
FocusFocus the grid.
FormatNumberFormat a number with an arbitrary formatter.
Freezeset freeze area
FreezeSelectionfreeze at current selection
GetFreezereturn current freeze area
GetRange
GetSelectionReturns the current selection, as a string address or range.
GetSheetIDGet sheet ID, by name (sheet name) or index.
GetStylereturns the style from the target address or range.
HideSheetShow or hide sheet.
InsertAnnotationInsert an annotation node.
InsertColumnsInsert column(s).
InsertImageInsert an image.
InsertRowsInsert row(s).
InsertTableinsert a table in the given range.
JavascriptDateconvert a spreadsheet date to a javascript date
LoadCSVLoad CSV from string.
LoadDocumentunserialize document from data.
LoadFromLocalStorageload a document from from local storage, using the given key.
LoadLocalFileLoad a desktop file.
LoadNetworkDocumentload a network document by URI.
MergeCellsMerge cells in range.
ParseNumberParse a string and return a number (if possible).
RecalculateRecalculate sheet.
RemoveConnectedChart
RemoveFunctionDelete a macro function.
RemoveTable
RenameSheetRename a sheet.
ResetClear/reset sheet.
ResizeUpdate layout and repaint if necessary.
ResolveResolve a string address/range to an address or area (range) object.
Revertrevert to the network version of this document, if `local_storage` is set and the create options had either `document` or `inline-document` set.
SaveLocalFile
SaveLocalStorageSave document to local storage.
SaveToDesktopSave the current document to a desktop file.
ScrollIntoViewscroll the given address into view.
ScrollOffsetget or set the current scroll offset.
ScrollToScroll to the given address.
SelectSelect a range.
SerializeDocumentSerialize document to a plain javascript object.
SetColumnWidthSet width of column(s).
SetLinkSet or remove a link in a cell.
SetNoteSet note (comment) in cell.
SetRangeSet data in range.
SetRowHeightSet height of row(s).
SetValidationset or clear cell valiation.
ShowSheetShow or hide sheet.
SortTablesort a table.
SpreadsheetDateconvert a javascript date (or timestamp) to a spreadsheet date
SubscribeSubscribe to spreadsheet events
UndoRevert state one level from the undo stack.
UnmergeCellsUnmerge cells in range.
UnresolveConvert an address/range object to a string.
UpdateConnectedChart
UpdateTableStyle
UpdateThemeUpdate theme from CSS.

active_sheet

convenience function returns the name of the active sheet. if the sheet name has spaces or other characters that require quoting, it will be quoted using single quotes.

Declaration
public get active_sheet(): string;
public get active_sheet(): string;
Type
string
string

can_revert

this flag indicates we can revert the document. what that means is we loaded a user-created version from localStorage, but there’s a backing network or inline document. or we did load the original version but the user has made some document changes.

it’s like dirty, but that uses the load source as the ground truth, which means if you load a modified document from localStorage it’s initially considered not-dirty (which is maybe just a bad design?)

the intent of this field is to support enabling/disabling revert logic, or to add a visual indicator that you are not looking at the canonical version.

Declaration
public get can_revert(): boolean;
public get can_revert(): boolean;
Type
boolean
boolean

dirty

indicates the current revision of the document is not equal to the last-saved revision of the document. explicitly set or clear the dirty flag. it’s intended for use by clients that have their own save routine.

Declaration
public get dirty(): boolean;
public set dirty(value: boolean): void;
public get dirty(): boolean;
public set dirty(value: boolean): void;
Type
boolean
boolean

document_name

document name (metadata)

Declaration
public get document_name(): string|undefined;
public set document_name(value: string|undefined): void;
public get document_name(): string|undefined;
public set document_name(value: string|undefined): void;
Type
string | undefined
string | undefined

headless

headless state

Declaration
public get headless(): boolean;
public set headless(value: boolean): void;
public get headless(): boolean;
public set headless(value: boolean): void;
Type
boolean
boolean

scale

current grid scale

Declaration
public get scale(): number;
public set scale(value: number): void;
public get scale(): number;
public set scale(value: number): void;
Type
number
number

sheet_names

returns the names of all sheets in the current document

Declaration
public get sheet_names(): string[];
public get sheet_names(): string[];
Type
string[]
string[]

state

state is the current revision of the document. it is preserved any time the document is saved. it should be a consistent indication of the document version and can be used to compare versions.

state is an atomically-incrementing integer but rolls over at 2^16.

Declaration
public get state(): number;
public get state(): number;
Type
number
number

user_data

opaque user data (metadata). USER_DATA_TYPE is a template parameter you can set when creating the spreadsheet.

Declaration
public get user_data(): USER_DATA_TYPE|undefined;
public set user_data(value: USER_DATA_TYPE|undefined): void;
public get user_data(): USER_DATA_TYPE|undefined;
public set user_data(value: USER_DATA_TYPE|undefined): void;
Type
USER_DATA_TYPE | undefined
USER_DATA_TYPE | undefined

About

Show the about dialog.

Signature
public About(): void;
public About(): void;
Returns
void
void

ActivateSheet

Activate sheet.

Signature
public ActivateSheet(index: number | string): void;
public ActivateSheet(index: number | string): void;
Returns
void
void
Parameters
index
number | string
number | string
sheet name or index.

AddSheet

Add a sheet, optionally named.

Signature
public AddSheet(name?: string): number;
public AddSheet(name?: string): number;
Returns
number
number
Parameters
nameoptional
string
string

ApplyBorders

Apply borders to range.

Borders are part of style, but setting/removing borders is more complicated than setting other style properties. usually you want things to apply to ranges, rather than individual cells. removing borders needs to consider neighbor borders. and so on.

Signature
public ApplyBorders(range: RangeReference | undefined, borders: BorderConstants, width?: number): void;
public ApplyBorders(range: RangeReference | undefined, borders: BorderConstants, width?: number): void;
Returns
void
void
Parameters
range
RangeReference | undefined
RangeReference | undefined
pass `undefined` as range to apply to current selection.
borders
widthoptional
number
number

ApplyStyle

Apply style to range.

Don’t use this method to set borders, use ApplyBorders.

Signature
public ApplyStyle(range?: RangeReference, style?: CellStyle, delta?: boolean): void;
public ApplyStyle(range?: RangeReference, style?: CellStyle, delta?: boolean): void;
Returns
void
void
Parameters
rangeoptionalpass `undefined` as range to apply to current selection.
styleoptional
deltaoptional
boolean
boolean
apply over existing properties. default true.

Batch

Use this function to batch multiple document changes. Essentially the grid stops broadcasting events for the duration of the function call, and collects them instead. After the function call we update as necessary.

Signature
public Batch(func: () => void, paint?: boolean): Promise<void>;
public Batch(func: () => void, paint?: boolean): Promise<void>;
Returns
Promise<void>
Promise<void>
Parameters
func
() => void
() => void
paintoptional
boolean
boolean

Cancel

Cancel subscription

Signature
public Cancel(token: number): void;
public Cancel(token: number): void;
Returns
void
void
Parameters
token
number
number
the token returned from `Subscribe`

ClearName

Remove a named range (removes the name, not the range).

Signature
public ClearName(name: string): void;
public ClearName(name: string): void;
Returns
void
void
Parameters
name
string
string

DefineFunction

Create a macro function.

FIXME: this needs a control for argument separator, like other functions that use formulas (@see SetRange)

Signature
public DefineFunction(name: string, argument_names?: string | string[], function_def?: string): void;
public DefineFunction(name: string, argument_names?: string | string[], function_def?: string): void;
Returns
void
void
Parameters
name
string
string
argument_namesoptional
string | string[]
string | string[]
function_defoptional
string
string

DefineName

Create a named range or named expression. A named range refers to an address or range. A named expression can be any value or formula. To set the value as a literal string, enclose the string in double-quotes (as you would when using a string as a function argument).

This function used to support passing undefined as the value, which meant “create a named range using current selection”. We don’t support that any more but you can accompilsh that with sheet.DefineName("Name", sheet.GetSelection()).

Signature
public DefineName(name: string, value: RangeReference | CellValue, scope?: string | number, overwrite?: boolean): void;
public DefineName(name: string, value: RangeReference | CellValue, scope?: string | number, overwrite?: boolean): void;
Returns
void
void
Parameters
name
string
string
valuerange, value or expression
scopeoptional
string | number
string | number
overwriteoptional
boolean
boolean

DeleteColumns

Delete columns(s).

Signature
public DeleteColumns(start_column?: number, count?: number): void;
public DeleteColumns(start_column?: number, count?: number): void;
Returns
void
void
Parameters
start_columnoptional
number
number
leave undefined to use current selection. in this case the `count` parameter will be ignored and all columns in the selection will be deleted.
countoptional
number
number

DeleteRows

Delete row(s).

Signature
public DeleteRows(start_row?: number, count?: number): void;
public DeleteRows(start_row?: number, count?: number): void;
Returns
void
void
Parameters
start_rowoptional
number
number
leave undefined to use current selection. in this case the `count` parameter will be ignored and all rows in the selection will be deleted.
countoptional
number
number

DeleteSheet

Delete a sheet.

Signature
public DeleteSheet(index?: string | number): void;
public DeleteSheet(index?: string | number): void;
Returns
void
void
Parameters
indexoptional
string | number
string | number
sheet name or index. Leave undefined to delete the active sheet.

Evaluate

Evaluate an arbitrary expression in the spreadsheet. You should generally use sheet names when referring to cells, to avoid ambiguity. Otherwise cell references will resolve to the active sheet.

Signature
public Evaluate(expression: string, options?: EvaluateOptions): CellValue | CellValue[][];
public Evaluate(expression: string, options?: EvaluateOptions): CellValue | CellValue[][];
Returns
Parameters
expression
string
string
an expression in spreadsheet language
optionsoptionaloptions for parsing the passed function

Export

Export to XLSX file.

this requires a bunch of processing — one, we do this in a worker, and two, it’s demand loaded so we don’t bloat up this embed script.

Signature
public Export(): void;
public Export(): void;
Returns
void
void

ExportDelimited

Export sheet as CSV/TSV. This is an internal method called by the save document methods, but you can call it directly if you want the text as a string.

Signature
public ExportDelimited(options?: ExportOptions): string;
public ExportDelimited(options?: ExportOptions): string;
Returns
string
string
Parameters
optionsoptional

ExternalEditor

set or remove an external editor. external editor is an interface used to support outside tooling by highlighting a list of arguments and responding to selection.

Signature
public ExternalEditor(config?: Partial<ExternalEditorConfig>): void;
public ExternalEditor(config?: Partial<ExternalEditorConfig>): void;
Returns
void
void
Parameters
configoptional

FilterTable

filter a table. the reference can be the table name, or a cell in the table. if the reference is an area (range), we’re going to look at the top-left cell.

this method uses a function to filter rows based on cell values. leave the function undefined to show all rows. this is a shortcut for “unfilter”.

Signature
public FilterTable(reference: RangeReference, column?: number, filter?: TableFilterFunction): void;
public FilterTable(reference: RangeReference, column?: number, filter?: TableFilterFunction): void;
Returns
void
void
Parameters
reference
columnoptional
number
number
the column to sort on. values from this column will be passed to the filter function.
filteroptionala callback function to filter based on cell values. this will be called with the cell value (formula), the calculated value (if any), and the cell style. return false to hide the row, and true to show the row. if the filter parameter is omitted, all values will be shown.

Focus

Focus the grid.

Signature
public Focus(): void;
public Focus(): void;
Returns
void
void

FormatNumber

Format a number with an arbitrary formatter.

Signature
public FormatNumber(value: number, format?: string): string;
public FormatNumber(value: number, format?: string): string;
Returns
string
string
Parameters
value
number
number
formatoptional
string
string

Freeze

set freeze area

Signature
public Freeze(rows?: number, columns?: number): void;
public Freeze(rows?: number, columns?: number): void;
Returns
void
void
Parameters
rowsoptional
number
number
columnsoptional
number
number

FreezeSelection

freeze at current selection

Signature
public FreezeSelection(): void;
public FreezeSelection(): void;
Returns
void
void

GetFreeze

return current freeze area

Signature
public GetFreeze(): FreezePane;
public GetFreeze(): FreezePane;
Returns

GetRange

undefined

Signature
public GetRange(range?: RangeReference, options?: GetRangeOptions): CellValue | CellValue[][] | undefined;
public GetRange(range?: RangeReference, options?: GetRangeOptions): CellValue | CellValue[][] | undefined;
Returns
CellValue | CellValue[][] | undefined
CellValue | CellValue[][] | undefined
Parameters
rangeoptionaltarget range. leave undefined to use current selection.
optionsoptional

GetSelection

Returns the current selection, as a string address or range.

Signature
public GetSelection(qualified?: boolean): string;
public GetSelection(qualified?: boolean): string;
Returns
string
string
Parameters
qualifiedoptional
boolean
boolean
include sheet name in result. default true.

GetSheetID

Get sheet ID, by name (sheet name) or index. This may be useful for constructing references programatically.

Sheet IDs are positive integers. IDs are ephemeral, they should not be retained after a document is closed or reloaded. They will likely (almost) always be the same, but that’s not guaranteed, so don’t rely on them.

Signature
public GetSheetID(sheet: string | number): number | undefined;
public GetSheetID(sheet: string | number): number | undefined;
Returns
number | undefined
number | undefined
Parameters
sheet
string | number
string | number
sheet name or index. sheet names are matched case-insensitively.

GetStyle

returns the style from the target address or range.

Signature
public GetStyle(range?: RangeReference, apply_theme?: boolean): CellStyle | CellStyle[][] | undefined;
public GetStyle(range?: RangeReference, apply_theme?: boolean): CellStyle | CellStyle[][] | undefined;
Returns
CellStyle | CellStyle[][] | undefined
CellStyle | CellStyle[][] | undefined
Parameters
rangeoptionaltarget range. leave undefined to use current selection
apply_themeoptional
boolean
boolean
include theme defaults when returning style

HideSheet

Show or hide sheet. This is a replacement for the ShowSheet method, because that name is somewhat ambiguous.

Signature
public HideSheet(index?: number | string, hide?: boolean): void;
public HideSheet(index?: number | string, hide?: boolean): void;
Returns
void
void
Parameters
indexoptional
number | string
number | string
sheet name or index.
hideoptional
boolean
boolean

InsertAnnotation

Insert an annotation node. Usually this means inserting a chart. Regarding the argument separator, see the Evaluate function.

Signature
public InsertAnnotation(formula: string, type?: AnnotationType, rect?: IRectangle | RangeReference, options?: EvaluateOptions | "," | ";"): void;
public InsertAnnotation(formula: string, type?: AnnotationType, rect?: IRectangle | RangeReference, options?: EvaluateOptions | "," | ";"): void;
Returns
void
void
Parameters
formula
string
string
annotation formula. For charts, the chart formula.
typeoptionalannotation type. Defaults to `treb-chart`.
rectoptionalcoordinates, or a range reference for layout.
optionsoptional
EvaluateOptions | ',' | ';'
EvaluateOptions | ',' | ';'
evaluate options. because this function used to take the argument separator, we allow that to be passed directly, but this is deprecated. new code should use the options object.

InsertColumns

Insert column(s).

Signature
public InsertColumns(before_column?: number, count?: number): void;
public InsertColumns(before_column?: number, count?: number): void;
Returns
void
void
Parameters
before_columnoptional
number
number
leave undefined to use current selection.
countoptional
number
number

InsertImage

Insert an image. This method will open a file chooser and (if an image is selected) insert the image into the document.

Signature
public InsertImage(): void;
public InsertImage(): void;
Returns
void
void

InsertRows

Insert row(s).

Signature
public InsertRows(before_row?: number, count?: number): void;
public InsertRows(before_row?: number, count?: number): void;
Returns
void
void
Parameters
before_rowoptional
number
number
leave undefined to use current selection.
countoptional
number
number

InsertTable

insert a table in the given range. optionally include a totals row. this method does not make any changes to content or layout. it just converts the range to a table.

Signature
public InsertTable(range?: RangeReference, options?: InsertTableOptions): void;
public InsertTable(range?: RangeReference, options?: InsertTableOptions): void;
Returns
void
void
Parameters
rangeoptional
optionsoptional

JavascriptDate

convert a spreadsheet date to a javascript date

Signature
public JavascriptDate(spreadsheet_date: number): number;
public JavascriptDate(spreadsheet_date: number): number;
Returns
number
number
Parameters
spreadsheet_date
number
number

LoadCSV

Load CSV from string. This is used internally when loading network documents and local files, but you can call it directly if you have a CSV file as text.

Signature
public LoadCSV(csv: string, source?: LoadSource): void;
public LoadCSV(csv: string, source?: LoadSource): void;
Returns
void
void
Parameters
csv
string
string
sourceoptional

LoadDocument

unserialize document from data.

Signature
public LoadDocument(data: TREBDocument, options?: LoadDocumentOptions): void;
public LoadDocument(data: TREBDocument, options?: LoadDocumentOptions): void;
Returns
void
void
Parameters
data
optionsoptional

LoadFromLocalStorage

load a document from from local storage, using the given key. this method will also set the local option for the storage key, so the document will potentially be saved on modification.

Signature
public LoadFromLocalStorage(key: string): boolean;
public LoadFromLocalStorage(key: string): boolean;
Returns
boolean
boolean
Parameters
key
string
string

LoadLocalFile

Load a desktop file. This method will show a file chooser and open the selected file (if any).

Signature
public LoadLocalFile(): Promise<void>;
public LoadLocalFile(): Promise<void>;
Returns
Promise<void>
Promise<void>

LoadNetworkDocument

load a network document by URI. CORS headers must be set appropriately on documents originating from different hosts.

Signature
public LoadNetworkDocument(uri: string, options?: EmbeddedSpreadsheetOptions): Promise<void>;
public LoadNetworkDocument(uri: string, options?: EmbeddedSpreadsheetOptions): Promise<void>;
Returns
Promise<void>
Promise<void>
Parameters
uri
string
string
optionsoptional

MergeCells

Merge cells in range.

Signature
public MergeCells(range?: RangeReference): void;
public MergeCells(range?: RangeReference): void;
Returns
void
void
Parameters
rangeoptionaltarget range. leave undefined to use current selection.

ParseNumber

Parse a string and return a number (if possible).

Signature
public ParseNumber(text: string): number | Complex | boolean | string | undefined;
public ParseNumber(text: string): number | Complex | boolean | string | undefined;
Returns
number | Complex | boolean | string | undefined
number | Complex | boolean | string | undefined
Parameters
text
string
string

Recalculate

Recalculate sheet.

Signature
public Recalculate(): Promise<void>;
public Recalculate(): Promise<void>;
Returns
Promise<void>
Promise<void>

RemoveConnectedChart

undefined

Signature
public RemoveConnectedChart(id: number): void;
public RemoveConnectedChart(id: number): void;
Returns
void
void
Parameters
id
number
number

RemoveFunction

Delete a macro function.

Signature
public RemoveFunction(name: string): void;
public RemoveFunction(name: string): void;
Returns
void
void
Parameters
name
string
string

RemoveTable

undefined

Signature
public RemoveTable(range?: RangeReference): void;
public RemoveTable(range?: RangeReference): void;
Returns
void
void
Parameters
rangeoptional

RenameSheet

Rename a sheet.

Signature
public RenameSheet(index: string | number | undefined, new_name: string): void;
public RenameSheet(index: string | number | undefined, new_name: string): void;
Returns
void
void
Parameters
index
string | number | undefined
string | number | undefined
old name or index of sheet. leave undefined to use current active sheet.
new_name
string
string

Reset

Clear/reset sheet. This will reset the undo stack as well, so it cannot be undone.

Signature
public Reset(): void;
public Reset(): void;
Returns
void
void

Resize

Update layout and repaint if necessary.

This method should be called when the container is resized, to trigger an update to layout. It should be called automatically by a resize observer set in the containing tag class, but you can call it manually if necessary.

Signature
public Resize(): void;
public Resize(): void;
Returns
void
void

Resolve

Resolve a string address/range to an address or area (range) object.

Signature
public Resolve(reference: string): ICellAddress | IArea | undefined;
public Resolve(reference: string): ICellAddress | IArea | undefined;
Returns
ICellAddress | IArea | undefined
ICellAddress | IArea | undefined
Parameters
reference
string
string
A string like "A1" or "Sheet1!B2:C3". If a sheet name is not included, the current active sheet is used. You can also pass a named range as reference.

Revert

revert to the network version of this document, if local_storage is set and the create options had either document or inline-document set.

FIXME: we should adjust for documents that fail to load.

Signature
public Revert(): void;
public Revert(): void;
Returns
void
void

SaveLocalFile

undefined

Signature
public SaveLocalFile(filename?: string, additional_options?: SaveOptions): void;
public SaveLocalFile(filename?: string, additional_options?: SaveOptions): void;
Returns
void
void
Parameters
filenameoptional
string
string
additional_optionsoptional

SaveLocalStorage

Save document to local storage.

Signature
public SaveLocalStorage(key?: string | undefined): void;
public SaveLocalStorage(key?: string | undefined): void;
Returns
void
void
Parameters
keyoptional
string | undefined
string | undefined
optional storage key. if omitted, the method will use the key from local options (set at create time).

SaveToDesktop

Save the current document to a desktop file. This is the new version of the method, renamed from SaveLocalFile.

Signature
public SaveToDesktop(filename?: string, additional_options?: SaveOptions): void;
public SaveToDesktop(filename?: string, additional_options?: SaveOptions): void;
Returns
void
void
Parameters
filenameoptional
string
string
Filename or extension to use the document name.
additional_optionsoptional

ScrollIntoView

scroll the given address into view. it could be at either side of the window. optionally use smooth scrolling.

Signature
public ScrollIntoView(address: AddressReference, smooth?: boolean): void;
public ScrollIntoView(address: AddressReference, smooth?: boolean): void;
Returns
void
void
Parameters
address
smoothoptional
boolean
boolean

ScrollOffset

get or set the current scroll offset. scroll offset is automatically saved if you save the document or switch tabs; this is for saving/ restoring scroll if you cache the containing element.

Signature
public ScrollOffset(offset?: Point): Point | undefined;
public ScrollOffset(offset?: Point): Point | undefined;
Returns
Point | undefined
Point | undefined
Parameters
offsetoptional

ScrollTo

Scroll to the given address. In the current implementation this method will not change sheets, although it probably should if the reference is to a different sheet.

Signature
public ScrollTo(address: AddressReference, options?: SheetScrollOptions): void;
public ScrollTo(address: AddressReference, options?: SheetScrollOptions): void;
Returns
void
void
Parameters
address
optionsoptional

Select

Select a range. This function will change sheets if your reference refers to a different sheet. if the argument is undefined or falsy it will remove the selection (set to no selection).

Signature
public Select(range?: RangeReference): void;
public Select(range?: RangeReference): void;
Returns
void
void
Parameters
rangeoptional

SerializeDocument

Serialize document to a plain javascript object. The result is suitable for converting to JSON. This method is used by the SaveLocalFile and SaveLocalStorage methods, but you can call it directly if you want to save the document some other way.

Signature
public SerializeDocument(options?: SerializeOptions): TREBDocument;
public SerializeDocument(options?: SerializeOptions): TREBDocument;
Returns
Parameters
optionsoptional

SetColumnWidth

Set width of column(s).

Signature
public SetColumnWidth(column?: number | number[], width?: number): void;
public SetColumnWidth(column?: number | number[], width?: number): void;
Returns
void
void
Parameters
columnoptional
number | number[]
number | number[]
column, or columns (array), or undefined means all columns
widthoptional
number
number
desired width (can be 0) or undefined means 'auto-size'

Set or remove a link in a cell.

Signature
public SetLink(address?: AddressReference, target?: string): void;
public SetLink(address?: AddressReference, target?: string): void;
Returns
void
void
Parameters
addressoptional
targetoptional
string
string
http/https URL or a spreadsheet reference (as text). set blank to remove link.

SetNote

Set note (comment) in cell.

Signature
public SetNote(address: AddressReference | undefined, note?: string): void;
public SetNote(address: AddressReference | undefined, note?: string): void;
Returns
void
void
Parameters
address
AddressReference | undefined
AddressReference | undefined
target address, or leave undefined to use current selection.
noteoptional
string
string
note text, or leave undefined to clear existing note.

SetRange

Set data in range.

Signature
public SetRange(range?: RangeReference, data?: CellValue | CellValue[][], options?: SetRangeOptions): void;
public SetRange(range?: RangeReference, data?: CellValue | CellValue[][], options?: SetRangeOptions): void;
Returns
void
void
Parameters
rangeoptionaltarget range. leave undefined to use current selection.
dataoptional
optionsoptional

SetRowHeight

Set height of row(s).

Signature
public SetRowHeight(row?: number | number[], height?: number): void;
public SetRowHeight(row?: number | number[], height?: number): void;
Returns
void
void
Parameters
rowoptional
number | number[]
number | number[]
row, or rows (array), or undefined means all rows
heightoptional
number
number
desired height (can be 0) or undefined means 'auto-size'

SetValidation

set or clear cell valiation.

Signature
public SetValidation(address: AddressReference, validation?: RangeReference | CellValue[], error?: boolean): void;
public SetValidation(address: AddressReference, validation?: RangeReference | CellValue[], error?: boolean): void;
Returns
void
void
Parameters
addresstarget cell
validationoptionala spreadsheet range, list of data, or undefined. pass undefined to remove existing cell validation.
erroroptional
boolean
boolean
setting an invalid value in the target cell is an error (and is blocked). defaults to false.

ShowSheet

Show or hide sheet. This method is deprecated because it’s ambiguous. To set a sheet’s visibility, use HideSheet. To activate a sheet, use ActivateSheet.

Signature
public ShowSheet(index?: number | string, show?: boolean): void;
public ShowSheet(index?: number | string, show?: boolean): void;
Returns
void
void
Parameters
indexoptional
number | string
number | string
sheet name or index.
showoptional
boolean
boolean

SortTable

sort a table. the reference can be the table name, or a cell in the table. if the reference is an area (range), we’re going to look at the top-left cell.

Signature
public SortTable(reference: RangeReference, options?: Partial<TableSortOptions>): void;
public SortTable(reference: RangeReference, options?: Partial<TableSortOptions>): void;
Returns
void
void
Parameters
reference
optionsoptional

SpreadsheetDate

convert a javascript date (or timestamp) to a spreadsheet date

Signature
public SpreadsheetDate(javascript_date: number | Date): number;
public SpreadsheetDate(javascript_date: number | Date): number;
Returns
number
number
Parameters
javascript_date
number | Date
number | Date

Subscribe

Subscribe to spreadsheet events

Signature
public Subscribe(subscriber: (event: EmbeddedSheetEvent) => void): number;
public Subscribe(subscriber: (event: EmbeddedSheetEvent) => void): number;
Returns
number
number
Parameters
subscriber
(event: EmbeddedSheetEvent) => void
(event: EmbeddedSheetEvent) => void
callback function

Undo

Revert state one level from the undo stack.

Signature
public Undo(): void;
public Undo(): void;
Returns
void
void

UnmergeCells

Unmerge cells in range.

Signature
public UnmergeCells(range?: RangeReference): void;
public UnmergeCells(range?: RangeReference): void;
Returns
void
void
Parameters
rangeoptionaltarget range. leave undefined to use current selection.

Unresolve

Convert an address/range object to a string. this is a convenience function for composing formulas.

Signature
public Unresolve(ref: RangeReference, qualified?: boolean, named?: boolean): string;
public Unresolve(ref: RangeReference, qualified?: boolean, named?: boolean): string;
Returns
string
string
Parameters
refsheet reference as a string or structured object
qualifiedoptional
boolean
boolean
include sheet names
namedoptional
boolean
boolean
resolve to named ranges, where applicable

UpdateConnectedChart

undefined

Signature
public UpdateConnectedChart(id: number, formula: string): void;
public UpdateConnectedChart(id: number, formula: string): void;
Returns
void
void
Parameters
id
number
number
formula
string
string

UpdateTableStyle

undefined

Signature
public UpdateTableStyle(range?: RangeReference, theme?: TableTheme | number): void;
public UpdateTableStyle(range?: RangeReference, theme?: TableTheme | number): void;
Returns
void
void
Parameters
rangeoptional
themeoptional
TableTheme | number
TableTheme | number

UpdateTheme

Update theme from CSS. Because the spreadsheet is painted, not rendered, you need to notifiy us if external style (CSS) properties have changed. We will update and repaint.

Signature
public UpdateTheme(): void;
public UpdateTheme(): void;
Returns
void
void