cli-anything-wps 是做什么的?
A command-line tool to control WPS Office via the COM automation interface. Supports WPS Writer, WPS Calc, and WPS Impress.
Prerequisites
- Windows OS
- WPS Office (installed, version 12.0+)
- Python 3.10+
- pywin32:
pip install pywin32
Installation
pip install -e .
cli-anything-wps --help
JSON-Driven PPT Auto-Generation ⭐ Production Core Workflow
This is the most commonly used mode: Search data → Generate matplotlib charts → Write JSON → One-click WPS COM generation.
Complete Workflow (6 Steps)
1. Extract template background: template.pptx → template_bg.png (960x540)
2. WebSearch data: Admissions scores / Subject rankings / Enrollment plans / Research data
3. matplotlib generate charts: Bar chart / Pie chart / Line chart / Horizontal bar / Bubble chart
4. Write data.json: 12-15 pages elements[] arrangement (title ≤ 4 chars + spacing ≥ 24pt)
5. python build_xxx.py: WPS COM builds slide by slide
6. Output: PPTX + PDF dual format
Standard Slide Order
S1 Cover → S2 Table of Contents → S3-S10 Content pages (charts + tables + cards) → S11 Summary card → S12 Acknowledgments
Element Type Routing
| type | Purpose |
|---|
text | Text box |
image | Image (including matplotlib charts) |
table | Table |
cards_2x3 | 2-row x 3-column colored cards |
cards_1x4_info | 4-column numerical stats cards |
card_list_wide | Table of contents numbered list |
tagline_bar | Page bottom summary bar |
Key Constraints ⚠️
- Title to content spacing: Title y=14 h=40 (ends at y≈54), first content element must start at y≥76-78 (≥24pt gap)
- Title max 4 characters, centered, SimHei 40-44pt, brand color, no decorative lines
- JSON Chinese-style quotes: Use 「」 instead of
"" for text citations
- All elements stay within canvas: 960×540, y+h≤518
- WPS COM:
Fill.ForeColor.RGB, SaveAs(path, 32) to export PDF
- Clean up before execution:
taskkill //F //IM wps.exe //T
Reference Examples
16 projects under the WPS/ directory:
| Project | Pages | Topic |
|---|
| Tsinghua PUMC/Lanzhou University/Tongji Medical College/Harbin Institute of Technology/Chongqing University/Nanhua University | 12 pages | University admissions |
| Sun Yat-sen University/USTC/UCAS | 15 pages | Prestigious university admissions |
| Fudan University | 12 pages | New engineering + Medical school |
| SUSTech Cancer Hospital | 12 pages | Joint Master/PhD program |
| Peking University/Tsinghua/SUSTech/HUST/Zhejiang University City College | 9-14 pages | University introductions |
python -c "import zipfile; ..."
python gen_charts.py
python -c "import json; json.load(open('data.json','r',encoding='utf-8'))"
taskkill //F //IM wps.exe //T
python build_xxx.py
CLI Command Structure
wps
├── document # Document management: new/open/save/info
├── writer # Writer: add-paragraph/heading/list/table/image
├── calc # Calc: set-cell/get-cell/set-range/merge-cells
├── impress # Impress: add-slide/remove-slide/set-content/add-element
├── style # Styles: create/modify/list/apply/remove
├── preset # Design presets: list/info/apply
├── export # Export: render output.pptx -p pptx
└── session # Session: status/undo/redo/history
Usage Examples
cli-anything-wps document new --type writer --name "Report" -o report.json
cli-anything-wps --project report.json writer add-heading -t "Annual Report" -l 1
cli-anything-wps --project report.json export render report.docx -p docx
cli-anything-wps --json document new --type writer --name "test"
Design Presets
| Preset | Color Scheme | Use Case |
|---|
| academic | Deep blue #1A3C8B | Academic defense / Grant applications |
| consultant | Deep blue #003366 + Bright cyan | Consulting reports |
| business | Business blue #005294 | Meeting reports / Courseware |
| tech | Near black #0F1423 | Tech / AI / Data reports |
Quality Review (5 Dimensions)
| 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 |