@casualoffice/sheets is now a public, installable npm package that
embeds a full spreadsheet editor (Univer Sheets under the hood) into a
host app. It exposes the unified cross-editor contract — the same
shapes @casualoffice/docs exposes — so a host that learns one editor
already knows the other. The host owns storage; the SDK stays
storage-unaware and hands you content snapshots to persist.
npm i @casualoffice/sheets
What ships
One package, one contract
documentMode—'editing' | 'viewing', reactive, set declaratively or viasetDocumentMode(). Supersedes the olderreadOnlyboolean.- Events, two ways — every canonical event is both an
on*prop (onReady,onChange,onSelectionChange,onSave,onError,onDirtyChange) and an.on(name, handler)/.off(name, handler)emitter on the handle. - Imperative API (
CasualSheetsAPI) —getContent/setContent,import/export(.xlsx),getSelection,focus,executeCommand/executeCommands,setDocumentMode/getDocumentMode, plus a rawuniverfacade escape hatch.getSnapshot/loadSnapshotremain as deprecated aliases. features— aRecord<string, boolean>flag-map that hides a chrome control and blocks its command; applies when built-in chrome is shown (chrome="minimal"orchrome="full").extensions— append custom toolbar items, menu entries, dialogs, and side panels on top of the built-in Office shell.
Collaboration and AI by config
- Collab — pass a declarative
collabprop and the SDK wires Yjs / Hocuspocus itself once the editor is ready, detaching on unmount. Omit it for a single-user editor. The host still owns persistence; collab is the realtime transport only. - AI — pass an
aiprop to mount a task-pane surface beside the grid;createSheetsAiTransport()selects the transport for the environment (desktop-native, collab-proxied, or direct).
Style isolation
CasualSheetsIframerenders the editor in an iframe and talks to it over theembedpostMessage protocol, withcspNoncesupport for strict-CSP hosts.
Where to start
The full integration guide — mounting, document mode, load/save, events, the imperative API, chrome and features, extensions, collab, AI, and appearance — is at /docs/sheets/sdk/.