← Back to blog
AiAbout 7 min read

A spreadsheet that an agent can edit without breaking undo

Published Nov 29, 2026
A spreadsheet that an agent can edit without breaking undo

Every company that has tried to give an agent access to a spreadsheet has hit the same wall, and it is not the wall you expect. Reading cells is easy. Writing cells is easy. What breaks is everything around the write: the formula that needs recalculating, the filter range that contains the inserted row, the undo step that has to restore both, and the collaborator who typed in the same cell ninety seconds ago.

Univer is a bet that this is a library problem. It has 32,127 stars, a TypeScript codebase, and an Apache-2.0 core that covers content models, a command system, formula and rendering engines, and the Facade API that applications talk to. The idea underneath is that a browser editor, a backend job and an agent all issue the same command against the same serialised document.

The seam is a snapshot, not a file

The thing worth understanding first is what Univer calls a Unit. A workbook, a document, a slide deck and a board each serialise into a plain snapshot: IWorkbookData, IDocumentData, ISlideData, IBoardData.

That snapshot is the unit of exchange. The browser editor loads one. A Node.js process can load the same one without rendering anything. An agent can load it, change a value, and save it back. Nobody is parsing an XLSX binary to do this, and nobody is pretending a file is a database.

XLSX, DOCX and PPTX still matter, but they sit at the edge. The Exchange layer converts OOXML into the snapshot and back. Once the file is in, everything downstream works on the same content model, which means the thing your agent edits is the same thing your user sees.

Commands, not writes

The second idea is that edits are commands. Inserting a row inside a filter range is one command that touches two features, and each feature contributes its own change data and its own undo data. The command composes both, so undo restores both.

This matters more for agents than for humans. A human who deletes the wrong row presses undo and moves on. An agent that deletes the wrong row will, if it is well behaved, try to fix it by inserting what it thinks was there, which is a second error on top of the first. If the agent issues commands through the same system the UI uses, the recovery path already exists.

The Facade API is how that happens. It is the application-facing layer over workbooks, worksheets and ranges, and its documented promise is narrow and useful: an application control or an agent can make the same edit. Same commands, same history, same calculation.

Here is the smallest useful version of that, from the README's quick start.

pnpm add @univerjs/presets @univerjs/preset-sheets-core
import { UniverSheetsCorePreset } from '@univerjs/preset-sheets-core'
import UniverPresetSheetsCoreEnUS from '@univerjs/preset-sheets-core/locales/en-US'
import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'
import '@univerjs/preset-sheets-core/lib/index.css'
const { univerAPI } = createUniver({
  locale: LocaleType.EN_US,
  locales: {
    [LocaleType.EN_US]: mergeLocales(UniverPresetSheetsCoreEnUS),
  },
  presets: [UniverSheetsCorePreset({ container: 'app' })],
})
univerAPI.createWorkbook({})

Two details in there are easy to skim past. The presets bundle plugins and register their Facade APIs, so the shortcut is not a different API, just fewer lines. And if you mount this inside a component framework, you keep the univer instance and call dispose() on unmount, because the instance owns listeners and a render loop that will not clean itself up.

Headless is the part agents need

Most spreadsheet libraries assume a screen. Univer splits the editor from the engine, and the engine runs in Node. That is what makes a server-side agent plausible: it can open a workbook, apply commands, recalculate formulas, and write the snapshot back without ever starting a browser.

The commercial side is where the line is drawn. The repository ships the core architecture under Apache-2.0, plus Sheets and Docs editing. Slides, relational tables, canvases, the Server SDK and the commercial AI SDK extensions are licensed separately. The AI SDK is the piece that connects Office capabilities to existing agents, with content tools, execution and review, and it is not in the open core.

That split is normal for this kind of project and still worth stating plainly, because a team that prototypes on the open packages and then discovers the deployment path runs through commercial modules has a bad week.

What this is actually for

Three patterns justify the architecture.

The first is embedding. You have a product with data in it and you want a real grid inside it, not a read-only table. You keep your own data layer and use Facade to push edits in and pull snapshots out.

The second is headless processing. You have ten thousand workbooks and a nightly job. You do not need a renderer. You need a formula engine and a command model that will not corrupt a merged cell.

The third is the one this blog cares about. You have an agent that produces or edits structured content, and you want its output to be reviewable by a person in the same surface. A snapshot plus a command history gives you that review for free: the human opens the workbook, sees the agent's changes in the undo stack, and can reverse any of them without asking the agent to reverse them.

A worked case: the quotation that recalculates

The README's own follow-up exercise is a quotation sheet. You populate line items, change a quantity from application code, and read back the recalculated total.

That sounds trivial until you try it in a spreadsheet library that treats values as data. Set a quantity to 3, and the row total needs to become unit price times 3. If the row total is a formula, the formula engine has to notice the dependency and recalculate. If the total at the bottom sums the rows, that has to recalculate too. If a collaborator has the same workbook open, the change has to arrive as an operation they can merge, not as a new version that overwrites their column.

Univer handles this because a command runs through the same pipeline whether it came from a keystroke, an API call or an agent. The formula engine is a plugin, not a side effect of rendering, so it runs in a headless Node process just as well as in a browser.

For an agent product, that is the difference between generating a CSV and editing a document. A CSV is a snapshot. A workbook with command history is a conversation, and conversations can be reviewed.

Collaboration is where the abstraction earns its keep

Multi-user editing is the hardest thing in this category, and Univer's architecture is clearly built around it rather than retrofitted.

Because every edit is a command with declared changes and undo data, the transport layer only has to carry commands and their order. Two users inserting rows in different places do not need to reconcile cell values, because the operations are already the unit of merge. The same holds for an agent working alongside a person: the agent issues commands, the human issues commands, and the command log is the shared truth.

That is also why the version discipline in the README is so strict. If a plugin contributes changes but not undo data, the history silently diverges between clients. The coordination rules around @univerjs/* versions exist because the command model is a contract, and a contract with mixed versions is not a contract.

The limits worth knowing before you commit

Univer is not a drop-in Excel replacement, and the README does not pretend it is. The feature comparison page is maintained by the project, which means it is accurate about scope and optimistic about polish.

Version discipline is strict. Coordinated @univerjs/* packages need to stay on the same version, commercial packages need the matching release line, and the project publishes an API stability policy because extension points are not all frozen. If you depend on internals rather than Facade, you will feel every minor release.

The rendering engine is the heaviest part by far. A sheet with a hundred thousand rows and conditional formatting everywhere will not feel like a native app on a laptop from 2019, and the preset install pulls a lot of CSS. For a review surface that is fine. For a data-heavy dashboard, measure before you decide.

None of that changes the core observation. Agents struggle with spreadsheets for reasons that have nothing to do with arithmetic: the spreadsheet is a stateful, collaborative, undoable document, and handing an agent a cell-write API is like handing someone a scalpel and calling it surgery. Univer's contribution is to insist that the agent go through the same door as everyone else, and to make the door a command.

Turn ideas into images with ChatPicture

60 free credits every day. Generate, edit, and download — no prompt engineering degree required.

Related articles