English | 简体中文
This repository contains runnable teaching examples for the Univer CLI SDK. Concepts and architecture live on the Univer Office documentation site.
| Example | Learn | New concepts |
|---|---|---|
01-content-operations |
Read, edit, and view Sheet, Doc, and Slide Units | CLI, Server, Web, Collaboration Runtime |
02-file-exchange |
Import and export Office files | Exchange, UnitData, native binding |
03-visual-inspection |
Visually inspect all three Unit types | Render Page, Screenshot, Layout Lint |
04-worktree |
Edit in a draft and hand it to a human for review | Worktree, Ready, Merge, Reopen, Discard |
Read them in numbered order. Each directory has its own package.json, lockfile, and dependencies,
so it can be copied and run independently.
cd examples/01-content-operations
pnpm install
pnpm build
pnpm link-cli
pnpm start-serverAfter the Server starts, install the skill from another terminal in the same directory:
pnpm skill:installOpen the 01-content-operations directory with an Agent and enter:
Use univer-content to create a sales spreadsheet with 10 sample records.
cd examples/02-file-exchange
pnpm install
pnpm build
pnpm link-cli
pnpm start-serverUse another terminal in the same 02-file-exchange directory:
UNIT_ID=$(univer-example-cli create sheet --name "Exchange Demo")
univer-example-cli export demo.xlsx --unit "$UNIT_ID"
IMPORTED_ID=$(univer-example-cli import demo.xlsx)cd examples/03-visual-inspection
pnpm install
pnpm build
pnpm link-cli
pnpm start-serverUse another terminal in the same 03-visual-inspection directory:
UNIT_ID=$(univer-example-cli create sheet --name "Visual Demo")
univer-example-cli screenshot --unit "$UNIT_ID" --sheet Data --range A1:B2 --out outputcd examples/04-worktree
pnpm install
pnpm build
pnpm link-cli
pnpm start-serverUse another terminal in the same directory:
UNIT_ID=$(univer-example-cli create sheet --name "Worktree Demo")
WORKTREE_ID=$(univer-example-cli worktree create --unit "$UNIT_ID")
univer-example-cli open --unit "$UNIT_ID" --worktree "$WORKTREE_ID"See each example README for its complete command sequence and verification steps. These are minimal teaching assemblies, not production applications; they do not add production authorization, upload tasks, Daemon, or similar product mechanisms.