cli-anything-wps
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecli-anything-wps
cli-anything-wps
通过 COM 自动化接口操控 WPS Office 的命令行工具。支持 WPS 文字(Writer)、WPS 表格(Calc)和 WPS 演示(Impress)。
A command-line tool for controlling WPS Office through the COM automation interface. Supports WPS Writer, WPS Calc, and WPS Impress.
前置条件
Prerequisites
- Windows 操作系统
- WPS Office(已安装,版本 12.0+)
- Python 3.10+
- pywin32:
pip install pywin32
- Windows operating system
- WPS Office (installed, version 12.0+)
- Python 3.10+
- pywin32:
pip install pywin32
安装
Installation
bash
pip install -e .
cli-anything-wps --helpbash
pip install -e .
cli-anything-wps --helpJSON 数据驱动 PPT 自动生成 ⭐ 生产环境核心工作流
JSON-Driven Automated PPT Generation ⭐ Production-Ready Core Workflow
这是最常用的模式:搜数据 → 生成 matplotlib 图表 → 写 JSON → WPS COM 一键生成。
This is the most commonly used workflow: search for data → generate matplotlib charts → write JSON → generate everything with WPS COM in one click.
完整流程(6步)
Complete Workflow (6 Steps)
1. 提取模板背景: 模版.pptx → template_bg.png (960x540)
2. WebSearch 搜索数据: 招生分数线/学科排名/招生计划/科研数据
3. matplotlib 生成图表: 柱状图/饼图/折线图/横向柱/气泡图
4. 编写 data.json: 12-15页 elements[] 编排(标题≤4字 + 间距≥24pt)
5. python build_xxx.py: WPS COM 逐页构建
6. 输出: PPTX + PDF 双格式1. 提取模板背景: 模版.pptx → template_bg.png (960x540)
2. WebSearch 搜索数据: 招生分数线/学科排名/招生计划/科研数据
3. matplotlib 生成图表: 柱状图/饼图/折线图/横向柱/气泡图
4. 编写 data.json: 12-15页 elements[] 编排(标题≤4字 + 间距≥24pt)
5. python build_xxx.py: WPS COM 逐页构建
6. 输出: PPTX + PDF 双格式标准页序
Standard Page Sequence
S1 封面 → S2 目录 → S3-S10 内容页(图+表+卡片) → S11 总结卡片 → S12 致谢S1 封面 → S2 目录 → S3-S10 内容页(图+表+卡片) → S11 总结卡片 → S12 致谢元素类型路由
Element Type Routing
| type | 用途 |
|---|---|
| 文本框 |
| 图片(含matplotlib图表) |
| 表格 |
| 2行x3列彩色卡片 |
| 4列数字统计卡 |
| 目录编号列表 |
| 页面底部总结条 |
| type | Purpose |
|---|---|
| Text box |
| Image (including matplotlib charts) |
| Table |
| 2-row × 3-column colored cards |
| 4-column numeric statistics cards |
| Numbered table-of-contents list |
| Bottom summary bar |
关键约束 ⚠️
Key Constraints ⚠️
- 标题与内容间距:标题 y=14 h=40(结束于y≈54),第一个内容元素必须起始于 y≥76-78(≥24pt gap)
- 标题最多4字,居中,SimHei 40-44pt,品牌色,无装饰线
- JSON中文引号:文本内引用用「」代替
"" - 所有元素不出画布:960×540,y+h≤518
- WPS COM:,
Fill.ForeColor.RGB导出PDFSaveAs(path, 32) - 执行前清理:
taskkill //F //IM wps.exe //T
- Title-to-content spacing: title y=14 h=40 (ends at y≈54), and the first content element must start at y≥76-78 (≥24pt gap)
- Title length: no more than 4 Chinese characters, centered, SimHei 40-44pt, brand color, no decorative line
- JSON quotation marks: use 「」 instead of for quotations within text
"" - Keep all elements inside the canvas: 960×540, y+h≤518
- WPS COM: ; export PDF with
Fill.ForeColor.RGBSaveAs(path, 32) - Clean up before execution:
taskkill //F //IM wps.exe //T
参考案例
Reference Examples
WPS/ 目录下16个项目:
| 项目 | 页数 | 主题 |
|---|---|---|
| 清华协和/兰州大学/同济医学院/哈工大/重庆大学/南华大学 | 12页 | 各校招生 |
| 中山大学/中科大/国科大 | 15页 | 名校招生 |
| 复旦大学 | 12页 | 新工科+医学院 |
| 南科大肿瘤医院 | 12页 | 联合培养硕博 |
| 北大/清华/南科大/华中科大/浙大城市学院 | 9-14页 | 各校介绍 |
bash
undefinedThe WPS/ directory contains 16 projects:
| Project | Pages | Topic |
|---|---|---|
| Tsinghua Union/Lanzhou University/Tongji Medical College/Harbin Institute of Technology/Chongqing University/University of South China | 12 pages | University admissions |
| Sun Yat-sen University/University of Science and Technology of China/University of Chinese Academy of Sciences | 15 pages | Elite university admissions |
| Fudan University | 12 pages | New engineering + medical school |
| SUSTech Cancer Hospital | 12 pages | Joint master's and doctoral programs |
| Peking University/Tsinghua University/Southern University of Science and Technology/Huazhong University of Science and Technology/Zhejiang University City College | 9-14 pages | University profiles |
bash
undefined完整执行示例
完整执行示例
python -c "import zipfile; ..." # 提取模板
python gen_charts.py # 生成图表
python -c "import json; json.load(open('data.json','r',encoding='utf-8'))" # 验证JSON
taskkill //F //IM wps.exe //T
python build_xxx.py # 构建PPTX+PDF
---python -c "import zipfile; ..." # 提取模板
python gen_charts.py # 生成图表
python -c "import json; json.load(open('data.json','r',encoding='utf-8'))" # 验证JSON
taskkill //F //IM wps.exe //T
python build_xxx.py # 构建PPTX+PDF
---CLI 命令结构
CLI Command Structure
wps
├── document # 文档管理: new/open/save/info
├── writer # 文字: add-paragraph/heading/list/table/image
├── calc # 表格: set-cell/get-cell/set-range/merge-cells
├── impress # 演示: add-slide/remove-slide/set-content/add-element
├── style # 样式: create/modify/list/apply/remove
├── preset # 设计预设: list/info/apply
├── export # 导出: render output.pptx -p pptx
└── session # 会话: status/undo/redo/historywps
├── document # 文档管理: new/open/save/info
├── writer # 文字: add-paragraph/heading/list/table/image
├── calc # 表格: set-cell/get-cell/set-range/merge-cells
├── impress # 演示: add-slide/remove-slide/set-content/add-element
├── style # 样式: create/modify/list/apply/remove
├── preset # 设计预设: list/info/apply
├── export # 导出: render output.pptx -p pptx
└── session # 会话: status/undo/redo/history使用示例
Usage Examples
bash
undefinedbash
undefined创建文档
创建文档
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 export render report.docx -p docx
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 export render report.docx -p docx
JSON模式(Agent使用)
JSON模式(Agent使用)
cli-anything-wps --json document new --type writer --name "test"
undefinedcli-anything-wps --json document new --type writer --name "test"
undefined设计预设
Design Presets
| 预设 | 配色 | 适用场景 |
|---|---|---|
| academic | 深蓝#1A3C8B | 学术答辩/基金申请 |
| consultant | 深蓝#003366+亮青 | 咨询报告 |
| business | 商务蓝#005294 | 会议汇报/课件 |
| tech | 近黑#0F1423 | 科技/AI/数据报告 |
| Preset | Color Scheme | Use Case |
|---|---|---|
| academic | Dark Blue #1A3C8B | Academic defense/fund application |
| consultant | Dark Blue #003366 + Bright Cyan | Consulting report |
| business | Business Blue #005294 | Meeting report/courseware |
| tech | Near Black #0F1423 | Technology/AI/data report |
质量审查(5维度)
Quality Review (5 Dimensions)
| 维度 | 检查项 | 阈值 |
|---|---|---|
| visual | 字体层级/对比度/留白 | 70分 |
| pedagogy | 叙事弧/预备知识 | 75分 |
| proofreading | 拼写/术语/溢出 | 80分 |
| parity | PPTX/PDF一致性 | 85分 |
| substance | 数据准确性/引用 | 90分 |
| Dimension | Check Items | Threshold |
|---|---|---|
| visual | Font hierarchy/contrast/whitespace | 70 points |
| pedagogy | Narrative arc/prerequisite knowledge | 75 points |
| proofreading | Spelling/terminology/overflow | 80 points |
| parity | PPTX/PDF consistency | 85 points |
| substance | Data accuracy/citations | 90 points |