A command-line tool for controlling WPS Office through the COM automation interface. Supports WPS Writer, WPS Spreadsheets (Calc), and WPS Presentation (Impress).
Prerequisites
- Windows operating system
- WPS Office(installed, version 12.0+)
- Python 3.10+
- pywin32:
pip install pywin32
Installation
pip install -e .
# 验证
cli-anything-wps --help
Command structure
wps
├── document # 文档管理
│ ├── new # 创建新文档
│ ├── open # 打开项目文件
│ ├── save # 保存文档
│ ├── info # 文档信息
│ ├── profiles # 页面配置列表
│ └── json # 打印原始 JSON
├── writer # WPS 文字
│ ├── add-paragraph
│ ├── add-heading
│ ├── add-list
│ ├── add-table
│ ├── add-page-break
│ ├── add-image
│ ├── remove
│ ├── list
│ ├── set-text
│ └── find-replace
├── calc # WPS 表格
│ ├── add-sheet
│ ├── remove-sheet
│ ├── rename-sheet
│ ├── set-cell
│ ├── get-cell
│ ├── set-range
│ ├── merge-cells
│ └── list-sheets
├── impress # WPS 演示
│ ├── add-slide
│ ├── remove-slide
│ ├── set-content
│ ├── list-slides
│ └── add-element
├── style # 样式管理
│ ├── create
│ ├── modify
│ ├── list
│ ├── apply
│ └── remove
├── preset # 设计预设(PPT风格一键切换)
│ ├── list # 列出所有预设
│ ├── info [name] # 查看预设详情
│ └── apply [name] # 应用设计预设
├── export # 导出
│ ├── presets # 列出预设
│ ├── preset-info # 预设详情
│ └── render # 导出到文件
└── session # 会话管理
├── status
├── undo
├── redo
└── history
Usage examples
Create and edit documents
# 创建新文档
cli-anything-wps document new --type writer --name "报告" -o report.json
# 添加内容
cli-anything-wps --project report.json writer add-heading -t "年度报告" -l 1
cli-anything-wps --project report.json writer add-paragraph -t "这是报告正文内容。"
cli-anything-wps --project report.json writer add-table -r 3 -c 3
# 导出为 DOCX
cli-anything-wps --project report.json export render report.docx -p docx
# 导出为 PDF
cli-anything-wps --project report.json export render report.pdf -p pdf
Working with spreadsheets
cli-anything-wps document new --type calc --name "数据" -o data.json
cli-anything-wps --project data.json calc set-cell A1 "姓名"
cli-anything-wps --project data.json calc set-cell B1 "年龄"
cli-anything-wps --project data.json calc set-range A2 -d '[["张三",28],["李四",35]]'
cli-anything-wps --project data.json export render data.xlsx -p xlsx
JSON output (for Agent use)
# 所有命令都支持 --json 标志用于机器解析
cli-anything-wps --json document new --type writer --name "test"
cli-anything-wps --json --project test.json session status
REPL mode
cli-anything-wps
#> document new --type writer --name "演示"
#> writer add-paragraph -t "你好 WPS!"
#> export render demo.docx -p docx
#> quit
Agent usage guide
- All commands support
--json, returning structured JSON - Use the
--projectflagload an existing project, then chain commands - Automatic session saving: in single-command mode, changes are saved automatically on exit
- REPL modesuitable for interactive exploration
- Make sure content is saved before exportingto the project file
Export presets
| Preset | Description | Applicable type |
|---|---|---|
| docx | Word document | writer |
| doc | Word 97-2003 | writer |
| PDF (from Writer) | writer | |
| txt | Plain text | writer |
| html | Web page | writer |
| xlsx | Excel workbook | calc |
| xls | Excel 97-2003 | calc |
| csv | CSV | calc |
| pdf-calc | PDF (from Calc) | calc |
| pptx | PowerPoint | impress |
| ppt | PowerPoint 97-2003 | impress |
| pdf-impress | PDF (from Impress) | impress |
How it works
This CLI communicates with WPS Office through the Windows COM interface:
KWPS.Application→ WPS WriterKET.Application→ WPS SpreadsheetsKWPP.Application→ WPS Presentation
The WPS COM API is highly compatible with the Microsoft Office VBA API.
PPT design style system
This tool includes 4 design presets, 14 layout templates, 4 presentation type presets, and 5-dimension quality review. It is automatically invoked when making a PPT to generate beautiful slides.
1. Design Presets
Switch with one click via preset apply <名称> . AI Agents should call this command before creating a PPT.
1. Academic defense (academic)
- Source: scientific-slides skill
- Color scheme: dark blue #1A3C8B / orange #E67733 / green #188050
- Font: Arial + Microsoft YaHei, title 40pt, body 24pt, caption 16pt
- Rules: visual priority 65% | colorblind-friendly | one topic per page | 40% whitespace | at most 6 bullet points
- Applicable: academic conferences, thesis defenses, grant applications, Journal Club
2. Consultant (consultant)
- Source: pptx-from-layouts skill
- Color scheme: dark blue #003366 / bright cyan #00A8E8 / orange #FF8C00
- Font: Arial + Microsoft YaHei, title 36pt, body 18pt, caption 14pt
- Rules: 59 grid layouts | medium density | 4-color limit | at most 5 bullet points
- Applicable: business plans, consulting reports, annual reports
3. Business report (business)
- Source: pptx skill
- Color scheme: business blue #005294 / accent red #C82828 / green #2DA050
- Font: Arial + Microsoft YaHei, title 36pt, body 18pt, caption 14pt
- Rules: Visual 45% | Whitespace 35% | Max 6 bullet points
- Applicable: Meeting reports, project proposals, teaching courseware
4. Tech Minimal (tech)
- Source: Modern tech design
- Color scheme: Near-black #0F1423 / bright cyan #00C8FF / orange-red #FF643C
- Font: Arial + Microsoft YaHei, title 44pt, body 20pt, caption 14pt
- Rules: Dark mode | 3-color minimal | Whitespace 50% | Max 4 bullet points | Low density
- Applicable: Tech product launches, AI/technology demos, data reports
II. Layout Templates
14 standard layouts, covering all PPT scenarios. Agents should select them in order when making a PPT.
| Template Name | Category | Purpose | Key Elements |
|---|---|---|---|
| cover | Cover | Opening title page | 72pt large text + decorative line + subtitle |
| toc | Table of Contents | Content navigation | Blue vertical line + rounded square numbers + 6 items |
| overview | Overview | Information overview | Dark banner + 2x4 cards + side honors column |
| timeline | Timeline | History/development | Dots + vertical line + date + event + notable quote card |
| grid_cards | Card Grid | People/landmarks/products | 4x2 grid + avatar circles + name + bio |
| quadrant | Four Quadrants | Comparison/classification | 2x2 layout + colored title blocks + content areas |
| stats | Number Statistics | Data display | 6 large numbers + bottom honors/notes area |
| three_col | Three-Column Comparison | Comparison of three options | Dark full-screen background + three columns side by side |
| pipeline | Flowchart | Pipeline/process | 6 colored modules + connecting arrows + summary bar |
| data_table | Data Table | Rankings/metrics | Table on the left + interpretation area on the right |
| content_image | Image and Text | Combining images and text | Text left, image right / image left, text right |
| closing | Conclusion | Closing page | Dark full-screen + summary + motto/contact information |
III. Talk Type Presets
Complete recommended slide sequences. Agents should select them by type.
conference (academic conference, 12-20 pages)
cover → toc → overview → timeline → quadrant → grid_cards
→ stats → pipeline → data_table → content_image
→ quadrant → timeline → stats → closing
Rules: Max 20 pages | Visual 65% | 1-2 core findings
business (business report, 8-15 pages)
cover → toc → overview → stats → three_col
→ pipeline → grid_cards → data_table → closing
Rules: Max 15 pages | Visual 50%
defense (thesis defense, 45-65 pages)
cover → toc → overview → timeline → quadrant → content_image
→ pipeline → data_table → stats → quadrant → timeline
→ stats → closing
Rules: Max 65 pages | Visual 60%
school (school introduction, 14 pages)
cover → toc → overview → timeline → three_col
→ grid_cards → quadrant → stats → closing
Rules: Max 14 pages | Visual 55%
IV. Quality Review Standards
5-dimension review to ensure PPT output quality.
| Dimension | Source | Check Item | Pass Threshold |
|---|---|---|---|
| visual (Visual) | slide-excellence | Font hierarchy, color contrast, whitespace ratio, layout consistency | 70 points |
| pedagogy (teaching methodology) | slide-excellence | Narrative arc completeness, prerequisite knowledge, examples, notation consistency | 75 points |
| proofreading (proofreading) | slide-excellence | Spelling, grammar, terminology, punctuation, font overflow | 80 points |
| parity (format consistency) | slide-excellence | PPTX/PDF consistency, font embedding, images, animation compatibility | 85 points |
| substance (content substance) | slide-excellence | Data accuracy, complete citations, conclusion support | 90 points |
V. Standard workflow for an Agent making a PPT
1. 确认主题和类型 → 选择预设和演讲类型
cli-anything-wps preset apply academic --talk-type conference
2. 按演讲类型序列逐页生成内容
每页应用对应的 layout template
3. 生成完成后执行质量审查
确保 visual >= 70, pedagogy >= 75
4. 导出 PPTX + PDF 双格式
cli-anything-wps export render output.pptx -p pptx
cli-anything-wps export render output.pdf -p pdf