Skip to content
Skills Library
Documents & office · Automation

wps-cli

/wps-cli

通过 WPS Office COM 自动化操作 Word/Excel/PPT/PDF 文档。76 条 CLI 命令,100% 格式保真,--json 输出适配 AI Agent。When you need to: create/edit Word documents (.docx), manipulate Excel spreadsheets (.xlsx) with formulas/charts/data-validation, build PowerPoint presentations (.pptx), process PDF files, batch convert office formats, fill Word templates with {{key}} placeholders, validate document formatting, or diagnose WPS COM issues. 当用户需要操作办公文档、填写模板、生成报表、处理PDF、诊断WPS环境时自动触发。

Repository
wps-cli ↗
Licence
MIT
Last repository change
08.06.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
5
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 08.06.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

通过 WPS Office COM 自动化操作 Word/Excel/PPT/PDF 文档。76 条 CLI 命令,100% 格式保真,--json 输出适配 AI Agent。When you need to: create/edit Word documents (.docx), manipulate Excel spreadsheets (.xlsx) with formulas/charts/data-validation, build PowerPoint presentations (.pptx), process PDF files, batch convert office formats, fill Word templates with {{key}} placeholders, validate document formatting, or diagnose WPS COM issues. 当用户需要操作办公文档、填写模板、生成报表、处理PDF、诊断WPS环境时自动触发。

Original author description

通过 WPS Office COM 自动化操作 Word/Excel/PPT/PDF 文档。76 条 CLI 命令,100% 格式保真,--json 输出适配 AI Agent。When you need to: create/edit Word documents (.docx), manipulate Excel spreadsheets (.xlsx) with formulas/charts/data-validation, build PowerPoint presentations (.pptx), process PDF files, batch convert office formats, fill Word templates with {{key}} placeholders, validate document formatting, or diagnose WPS COM issues. 当用户需要操作办公文档、填写模板、生成报表、处理PDF、诊断WPS环境时自动触发。

How it works

  1. 工作决策树
  2. 核心概念
  3. 使用须知(AI Agent 必读)
  4. 诊断工作流
  5. 参考文档
Original SKILL.md headings · 96 lines, 432 words
SKILL.md preview
---
name: wps-cli
description: "通过 WPS Office COM 自动化操作 Word/Excel/PPT/PDF 文档。76 条 CLI 命令,100% 格式保真,--json 输出适配 AI Agent。When you need to: create/edit Word documents (.docx), manipulate Excel spreadsheets (.xlsx) with formulas/charts/data-validation, build PowerPoint presentations (.pptx), process PDF files, batch convert office formats, fill Word templates with {{key}} placeholders, validate document formatting, or diagnose WPS COM issues. 当用户需要操作办公文档、填写模板、生成报表、处理PDF、诊断WPS环境时自动触发。"
---
# 设计参考: iOfficeAI/OfficeCLI (Apache 2.0, https://github.com/iOfficeAI/OfficeCLI)

# WPS CLI — AI Agent 办公文档操作

在终端里指挥 WPS Office 干活 — **真格式、真排版**。不模拟文件格式,直接驱动真实的 WPS 引擎。

## 工作决策树

```
用户请求操作办公文档?
├── Word (.docx/.doc/.wps)  → writer 子命令
│   ├── 查看/诊断     → writer view <file> [summary|issues|outline|annotated|stats]
│   ├── 模板填充     → writer merge template.docx --data '{...}'
│   ├── 查找替换     → writer replace <file> <old> <new>
│   ├── 表格操作     → writer table-get / table-insert
│   ├── 路径定位     → writer get <file> "<path>"
│   ├── 表单域/控件  → writer formfield-* / contentcontrol-*
│   └── 文档验证     → writer validate <file>
├── Excel (.xlsx/.xls/.csv)  → calc 子命令
│   ├── 查看/诊断     → calc view <file> [summary|issues|sheets]
│   ├── 单元格读写   → calc cell-get / cell-set / cell-range
│   ├── 公式设置     → calc cell-formula
│   ├── 图表创建     → calc chart-create
│   ├── 条件格式     → calc conditional-format-*
│   ├── 数据验证     → calc data-validation-*
│   ├── 迷你图       → calc sparkline-add
│   └── 排序         → calc sort
├── PPT (.pptx/.ppt)         → impress 子命令
│   ├── 查看/诊断     → impress view <file> [summary|issues|slides]
│   ├── 幻灯片管理   → impress slide-list / slide-add / slide-delete
│   ├── 文本/图片    → impress text-get / text-set / image-insert
│   └── 导出         → impress export-pdf
├── PDF (.pdf)               → pdf 子命令
│   ├── 合并/拆分    → pdf merge / split / extract-pages
│   ├── 水印         → pdf watermark
│   └── 信息         → pdf info
├── 格式转换                  → export 子命令
│   ├── 单文件       → export convert <file> <format>
│   └── 批量         → export batch "*.docx" -t pdf
├── 批量执行                  → batch 子命令
│   └── JSON数组     → wps batch -c '[...]'
└── 环境诊断                  → wps doctor / version
```

## 核心概念

### 三层架构

```
CLI 层 (typer) → Service 层 (业务逻辑) → COM Backend (win32com) → WPS Office 桌面应用
```

- **CLI 层**:参数解析 + JSON 输出格式化
- **Service 层**:业务逻辑,通过抽象接口调用后端
- **COM Backend**:封装 COM 细节,可替换为 LibreOffice / WebOffice

### SessionManager

管理 WPS 进程生命周期(启动/关闭/复用),线程安全(RLock),UUID 会话 ID。

### 路径定位语法

统一 1-based 路径,支持三种风格:
```
/section[1]/paragraph[3]          # Word:第1节第3段
/sheet["Sheet1"]/cell["C12"]      # Excel:Sheet1 的 C12
$Sheet1:A1                        # Excel 风格简写
/slide[1]/shape[2]                # PPT:第1张第2个形状
```

## 使用须知(AI Agent 必读)

1. **命令是同步阻塞的**:每次 COM 操作需数秒(启动 WPS + 打开文件),设计工作流时预留等待时间。
2. **文件扩展名白名单**:writer 仅接受 `.doc/.docx/.wps/.rtf/.txt/.html`;calc 仅接受 `.xls/.xlsx/.xlsm/.et/.csv`;impress 仅接受 `.ppt/.pptx/.pps/.dps`。
3. **公式安全限制**:`calc cell-formula` 禁止 SHELL/DDE/HYPERLINK/WEBSERVICE 等危险函数。
4. **路径限制**:不支持 UNC 路径和符号链接,仅本地绝对/相对路径。
5. **仅 Windows**:依赖 COM 和 win32com,WPS Office 2019+ 必须安装。
6. **全局选项**:所有命令支持 `--json` / `-j` 输出机器可读 JSON;`--help` 查看帮助。

## 诊断工作流

遇到问题时按此顺序排查:
1. `wps doctor` — 环境诊断(Python/pywin32/WPS 版本/COM 注册表)
2. `wps doctor --fix` — 自动修复 COM 注册问题(需管理员权限)
3. `wps doctor --report` — 生成脱敏报告粘贴到 GitHub Issue
4. `wps writer|calc|impress validate <file>` — 文档级验证

## 参考文档

以下参考文档按需加载,避免占用上下文窗口:

- [commands.md](references/commands.md) — 完整 76 条命令速查表
- [patterns.md](references/patterns.md) — 8 大常见使用模式(模板填充、报表生成、批量转换等)
- [mcp.md](references/mcp.md) — MCP 服务器配置与 27 个工具列表
- [json-schema.md](references/json-schema.md) — JSON 输出格式、错误 Schema、退出码语义
Files in this package (5)
  • SKILL.md 5 KB
  • references/commands.md 11 KB
  • references/json-schema.md 3 KB
  • references/mcp.md 3 KB
  • references/patterns.md 3 KB

Versions

The database has no other skills named wps-cli.

Database snapshot: 13.11.2026 · package version 117c38029967 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100office
    创建、读取、修改并校验 Word(docx)/ Excel(xlsx)/ PowerPoint(pptx)文档。当输入是这三类文件,或用户要求产出/修改文档、表格、演示文稿时使用。老式格式(.doc/.xls/.ppt)与 WPS 专有格式用 kind=com 老格式分册。
  • 90office-documents
    Create, edit and convert Word, Excel, PowerPoint and PDF artifacts with format-aware verification. Use when producing docx, xlsx, pptx or PDF files; preserve templates and actual document structure, and render or recalculate before delivery.
  • 100wps-batch-convert
    文档批量格式转换。把一个文件夹里的Word全转文本、Excel全导出CSV、 Markdown转Word,支持docx/txt/xlsx/csv/md等格式批量互转,一次搞定。 用于帮助用户批量转换文档格式。当用户提到批量转换、格式转换、导出时触发。 Batch converts documents between formats (docx/pdf/xlsx/csv/md).
  • 85office-parser
    Parse Microsoft Office documents — Word (.docx), PowerPoint (.pptx), and Excel (.xlsx) — with streaming extraction and chunking. Use when working with Office documents, spreadsheets, presentations, or when the user mentions docx, pptx, xlsx, Word, Excel, PowerPoint, Office files.
  • 100docview
    Show Word, Excel, PowerPoint, WPS, Pages/Keynote/Numbers, CSV and PDF files with their original layout inside the agent's own side panel or preview pane, instead of launching WPS, Microsoft Office or Preview. Use whenever the user asks to open, view, preview, read or "show me" a…
  • 95document-processing
    Create, edit, and analyze office documents (PDF, DOCX, PPTX, XLSX). Use when working with PDFs, Word documents, PowerPoint presentations, or Excel spreadsheets. Covers text extraction, form filling, document creation, and data analysis.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.