Skip to content

Framework bindings ​

All bindings mount <xlsx-editor> through the same mountEditor function in packages/bindings/src/index.ts, so every framework gets identical semantics.

Props ​

PropTypeDefaultNotes
workbookWorkbooknoneShown when a new object is passed. The workbook the editor emits is never assigned back (no loop).
bytesUint8Array | ArrayBuffernoneFile bytes; loaded again whenever a new array is passed.
srcstringnoneURL fetched and loaded when the string changes; the file name defaults to the URL's last segment.
fileNamestringBook1.xlsxForwarded only when the parent changes it, so File > Open in the editor can rename the workbook.
readOnlybooleanfalse
localestringenen, fr, de, es, zh-CN or a tag that maps to one (de-DE).
theme'light' | 'dark' | 'auto'autoauto follows the operating system.
authorNamestringAuthorRecorded on new comments.
validateReplacebooleanfalseCheck each replacement against the cell's data validation in Replace and Replace All and leave refused cells unchanged. Excel does not.
showToolbarbooleantrueThe ribbon.
showFormulaBarbooleantrueThe name box and formula bar.
hiddenActionsstring[][]Ribbon controls, title-bar items and context-menu entries to hide, by stable id.
ribbonAddInsRibbonAddInTab[]noneTabs the host adds after the built-in ones; see Ribbon add-in tabs.
themeColorsPartial<Record<...>>{}Token overrides, see theming.
collaborationXlsxCollaborationOptionsnoneShares the open workbook in a room while set; a new object rejoins, null leaves. See collaboration.
storageDocumentStoragenoneHost-owned storage: Save and Save As go to storage.save(), and File > Open to storage.open() when it has one.
fileProvidersCloudFileProvider[]noneCloud places File > Open offers next to "This device"; a workbook opened from one saves back to that file. Keep the array stable.
customizationExcelCustomizationnonecapabilities, ribbon.hiddenTabs, backstage.extraPages and contextMenu.extraCommands; keep the object stable (null restores the defaults).

Callbacks and events ​

Callback (React, Solid, vanilla)Vue eventAngular outputSvelte propPayload
onWorkbookChangeworkbook-changeworkbookChangeonworkbookchangeWorkbook
onWorkbookErrorworkbook-errorworkbookErroronworkbookerrorError
onSelectionChangeselection-changeselectionChangeonselectionchange{ sheet, ref, active }
onDirtyChangedirty-changedirtyChangeondirtychangeboolean
onReadOnlyChangereadonly-changereadOnlyChangeonreadonlychangeboolean
onFileCommandfile-commandfileCommandonfilecommandCustomEvent<FileCommandDetail>, cancelable
onWorkbookWarningworkbook-warningworkbookWarningonworkbookwarningstring[]
onRibbonActionribbon-actionribbonActiononribbonaction{ id }
onRibbonCustomizeribbon-customizeribbonCustomizeonribboncustomizestring[] (hidden actions)
onSheetChangesheet-changesheetChangeonsheetchange{ index, name }
onRibbonAddInoffice-ribbon-add-inribbonAddInonribbonaddin{ tab, command }
onCollaborationChangecollaboration-changecollaborationChangeoncollaborationchangeXlsxCollaborationState
onReadyreadyreadyonreadythe <xlsx-editor> element

Load failures (corrupt, encrypted or unsupported files) reach onWorkbookError; a failed src fetch does too. A src fetch still in flight is dropped when new bytes or a new workbook arrive, or src is cleared or changed.

onFileCommand receives the cancelable file-command event itself, not its detail: call event.preventDefault() to take a File command (New, Open, Save, Save As, Export, Export CSV, Print, Share) over, and read event.detail.command to see which one. Vue, Angular and Svelte emit or call back with the same event object. Every other callback receives its payload directly. See the element API.

Every prop is forwarded only when its value changes (hiddenActions and themeColors are compared by value), so a parent re-render never undoes what the user changed inside the editor: Editing / Viewing, File > Options theme or language, or Customize Ribbon. A controlled parent keeps its state in step through onReadOnlyChange and onRibbonCustomize (in Angular, [(readOnly)]).

Ribbon add-in tabs ​

A host can add its own ribbon tabs after Excel's own, as an Office add-in does. ribbonAddIns takes plain data and is a prop of every binding; a chosen command runs its run callback and is reported through onRibbonAddIn (Vue office-ribbon-add-in, Angular ribbonAddIn, Svelte onribbonaddin) with { tab, command }.

tsx
const tabs = [
	{
		id: 'reports',
		label: 'Reports',
		groups: [
			{
				label: 'Export',
				commands: [
					{ id: 'export', label: 'Export', icon: 'save', run: () => exportReport() },
					{ id: 'options', label: 'Options', size: 'small' },
					{ id: 'send', label: 'Send', items: [{ id: 'send-mail', label: 'By mail' }] },
				],
			},
		],
	},
];

<SpreadsheetEditor ribbonAddIns={tabs} onRibbonAddIn={({ tab, command }) => track(tab, command)} />;

size: 'small' commands fill columns of three and items makes a drop-down. Passing an equal descriptor again, as a framework does on every render, keeps the panels and only replaces the callbacks; leaving the prop out removes the tabs. A tab cannot take the id of a built-in tab, and its commands never reach the editor's own command handling. The same descriptor (RibbonAddInTab, from ooxml-core/ribbon, re-exported by every framework package) works in the Word, Excel, PowerPoint and Visio editors. No add-in tab ships with the editor.

Handle ​

Every adapter exposes the same handle: React through ref, Vue through the template ref, Angular through the component instance, Solid through editorRef, Svelte through the component's exports and vanilla as the return value of mountEditor.

MemberEffect
elementThe mounted <xlsx-editor>.
load(bytes, fileName?)Opens .xlsx, .xlsm, .xls or .csv bytes; rejects on failure.
newWorkbook()Replaces the workbook with a blank one.
save()Resolves to an .xlsx Blob. Does not clear dirty.
saveBytes(format?)'xlsx' (default) or 'csv' (active sheet) bytes.
download(fileName?)Saves, downloads in the browser and marks the workbook clean.
markClean()Clears dirty after you persisted a saved Blob yourself.
select(ref), getSelection()Selection as an A1 reference ('B2:D8').
setActiveSheet(index)Switches sheet.
share()Opens the Share dialog. Unmounting the editor leaves any shared room.
openCloudFile(file)Opens a file from a CloudFileProvider as File > Open > OneDrive does: its name, read-only state and storage for Save.
dirtyUnsaved edits. Svelte's isDirty() is deprecated; read dirty.

Calling a handle method before the editor is mounted throws Editor is not mounted.

Server rendering ​

Every package imports without a DOM. Registration (defineXlsxEditor) and mounting are client operations.

Released under the Apache-2.0 License.