📄 OfficeCLI:4.5k Stars,一行命令让你的 AI Agent 直接操控 Word/Excel/PPT,不用装 Office / OfficeCLI: Give Any AI Agent Full Control Over Office Documents Without Office
项目地址:iOfficeAI/OfficeCLI | ⭐ 4,530 Stars | 🛠 C# | 作者:iOfficeAI
老实说,每次让 AI 帮忙写文档,最后都得我自己手动排版。Agent 生成 Markdown 没问题,但你要它出个 PPT 或者改个 Excel 表格——它就傻了。
市面上的方案要么绑死某个 AI 产品,要么需要装几十 GB 的 Office 套件。别整那些花里胡哨的,你需要的就是一个能直接跟 .docx / .xlsx / .pptx 对话的命令行工具。
OfficeCLI 就是干这个的。一个二进制文件,零依赖,装完你的 Claude Code、Codex、Cursor 就能直接读写 Office 文档。最骚的操作是它自带渲染引擎——Agent 做完 PPT 能直接预览,不用开 PowerPoint。
装一下,一行命令
curl -fsSL https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.sh | bash
装完跑 officecli --version 确认。它会自动检测你电脑上的 Claude Code、Cursor、Copilot,把 skill 文件装好——Agent 立刻就能用。
让 Agent 30 秒做一份 PPT
从安装到出幻灯片,全在一个终端里:
# 创建空白 PPT
officecli create deck.pptx
# 启动实时预览(浏览器自动打开 http://localhost:26315)
officecli watch deck.pptx &
# 加一页
officecli add deck.pptx / --type slide --prop title="Q4 Report" --prop background=1A1A2E
# 加个文本框
officecli add deck.pptx '/slide[1]' --type shape \
--prop text="Revenue grew 25%" --prop x=2cm --prop y=5cm \
--prop font=Arial --prop size=24 --prop color=FFFFFF
每跑一条命令,浏览器里的预览就自动刷新一次。Agent 不用猜排版效果,它"看"得到。
不只是 PPT,Word 和 Excel 一样能打
Word 文档、Excel 表格、PPT 幻灯片,三个格式全支持。命令统一:
| 操作 | 命令 |
|---|---|
| 创建文档 | officecli create report.docx |
| 读取内容 | officecli view report.docx outline |
| 查元素结构 | officecli get deck.pptx / --depth 2 --json |
| 批量修改 | officecli batch budget.xlsx --input updates.json |
| 模板合并 | officecli merge template.docx --data data.json |
| 启动 MCP 服务 | officecli mcp |
每个命令都支持 --json 输出,Agent 拿到的数据直接解析,不用正则扒 stdout。
踩坑记录
- 路径寻址从 1 开始:
/slide[1]/shape[1]而不是[0],写 batch 的时候注意 - 颜色格式随意:
#FF0000、FF0000、red、rgb(255,0,0)都认 - 更新检查:后台自动检查新版,不想等可以
OFFICECLI_SKIP_UPDATE=1 - Windows 用户:PowerShell 安装
irm https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.ps1 | iex
要点总结:
- 一个二进制搞定 Word / Excel / PPT,无需安装 Office
- 所有命令输出 JSON,Agent 零心智负担
- 自带渲染引擎 + 实时预览,Agent 能"看"到自己在做什么
- 自动检测并注入 Claude Code / Cursor / Copilot skill
- 开源 Apache 2.0,随便改随便用