Skip to content

EditorHandle

What a host controls an editor through, whichever way it shows it: with in React, mountWorkbookEditor() on any page, or the element.

Property Modifier Type Description
editedCount readonly number Cells changed since the workbook was opened.
fileName readonly string The open workbook’s file name.
status readonly "error" | "empty" | "loading" | "ready" Whether a workbook is open, opening or couldn’t be opened.
unsaved readonly boolean There are changes the host hasn’t received through a save.
destroy(): void;

Stops the editor’s worker; mountWorkbookEditor’s handle unmounts the editor as well.

void


downloadCopy(): Promise<void>;

Downloads a copy as .xlsx without saving it to the host.

Promise<void>


downloadCsv(options?): Promise<void>;

Downloads the sheet shown, and only that sheet, as a CSV file (UTF-8 with a byte order mark), as the toolbar’s CSV button does. Values that would run as formulas in a spreadsheet app are escaped unless escapeFormulas is false.

Parameter Type
options? CsvOptions

Promise<void>


getCsv(options?): Promise<string | undefined>;

The sheet shown as CSV text, as downloadCsv writes it but without the byte order mark; undefined when it isn’t a worksheet.

Parameter Type
options? CsvOptions

Promise<string | undefined>


getWorkbook(): Promise<
| SavedWorkbook
| undefined>;

The workbook as it is now, as onSave would receive it, without save checks or onSave.

Promise< | SavedWorkbook | undefined>


goTo(ref): void;

Selects a cell or range, such as “B4” or “Prices!A1:C3”, or the range a defined name refers to, and shows it.

Parameter Type
ref string

void


open(bytes, fileName): Promise<boolean>;

Opens a workbook from its bytes, or a CSV file (.csv, .tsv or .txt, by its name) as a workbook of one sheet. Resolves true once it is open, and false when the user chose to keep the workbook already open, with its unsaved changes. Rejects, saying why, when the file can’t be opened; the editor shows the reason too. The bytes are copied, so the caller’s stay usable.

Parameter Type
bytes ArrayBuffer | Uint8Array<ArrayBufferLike>
fileName string

Promise<boolean>


registerSchema(schema): void;

Adds or replaces a schema and re-checks the open workbook.

Parameter Type
schema WorkbookSchema

void


removeSchema(id): void;
Parameter Type
id string

void


save(): Promise<SaveResult>;

Runs the same save as the Save button (schema checks, then onSave or a download), resolving with what happened.

Promise<SaveResult>


setCustomLists(lists): void;

Changes the lists that filling continues, as the customLists option gives them.

Parameter Type
lists string[][] | undefined

void


setLanguage(language): void;

Changes the language of the editor’s text while it is open.

Parameter Type
language string

void


setTheme(theme): void;

Changes the theme tokens while the editor is open.

Parameter Type
theme | Partial<Record< | "warning" | "text" | "colorScheme" | "accent" | "accentStrong" | "accentSoft" | "accentBorder" | "accentTint" | "onAccent" | "surface" | "surfaceAlt" | "surfaceSunken" | "backdrop" | "focusRing" | "textMuted" | "textSubtle" | "border" | "borderStrong" | "neutral" | "success" | "successSoft" | "successBorder" | "successText" | "warningSoft" | "warningBorder" | "warningText" | "warningAccent" | "danger" | "dangerSoft" | "dangerBorder" | "onDanger" | "infoSoft" | "infoText" | "infoAccent" | "infoBannerBg" | "infoBannerBorder" | "infoBannerText" | "fieldSoft" | "fieldText" | "noteSoft" | "noteText" | "noteBorder" | "noteTipBg" | "noteTipBorder" | "placeholderBg" | "placeholderBorder" | "placeholderText" | "placeholderTextMuted" | "dropzoneBorder" | "dropzoneHoverBg" | "gridBg" | "gridText" | "gridTextOnFill" | "gridLine" | "gridBorderAuto" | "gridFreezeLine" | "gridHeaderBg" | "gridHeaderText" | "gridHeaderLine" | "gridHeaderHoverBg" | "gridHeaderSelectedBg" | "gridHeaderSelectedText" | "gridRowHeaderText" | "gridTextMuted" | "gridTextLight" | "gridBgAlt" | "gridCutFill" | "gridSelection" | "gridSelectionFill" | "gridEditedFill" | "gridEditedMark" | "gridLockedFill" | "gridLabelFill" | "gridErrorMark" | "gridWarningMark" | "gridPendingMark" | "gridNoteMark" | "gridStaleMark" | "gridUnsupportedMark" | "gridSpillLine" | "gridDropdownArrow" | "gridLink" | "gridFont" | "gridHeaderFont" | "gridHeaderFontSize" | "gridHeaderFontWeight" | "formulaRef1" | "formulaRef2" | "formulaRef3" | "formulaRef4" | "formulaRef5" | "formulaRef6" | "formulaRef7" | "chartColors" | "font" | "fontMono" | "fontSize" | "fontSizeXs" | "fontSizeSm" | "fontSizeMd" | "fontSizeLg" | "fontSizeXl" | "iconStrokeWidth" | "radius" | "radiusSm" | "radiusLg" | "shadow" | "shadowSm", string>> | undefined

void


setUser(user): void;

Changes the name recorded against each action in the change history.

Parameter Type
user string | undefined

void


subscribe(listener): () => void;

Calls listener whenever the editor’s state changes; returns an unsubscribe function.

Parameter Type
listener () => void

() => void