Communitygithub.com

cli-anything-wps

A CLI tool to control WPS Office via COM automation, enabling JSON-driven PPT generation and command-line manipulation of WPS Writer, Calc, and Impress.

What is cli-anything-wps?

cli-anything-wps is a Python-based command-line tool that leverages the COM automation interface to programmatically control WPS Office on Windows. It supports all three major WPS applications: Writer (word processing), Calc (spreadsheets), and Impress (presentations). The tool is designed with a JSON-driven workflow, making it particularly well-suited for AI agents that need to generate data-rich presentations. A core production use case is generating PPTs from structured JSON: the agent searches for data, generates matplotlib charts, writes a JSON configuration file describing 12-15 slides with elements like text boxes, images, tables, and card layouts, and then executes a single command to build both PPTX and PDF outputs. The CLI is organized into subcommands for document management, writer, calc, impress, styling, presets, export, and session control. Built-in quality checks across five dimensions (visual, pedagogy, proofreading, parity, substance) ensure professional-grade results. This skill is ideal for developers and AI agents needing to automate WPS Office tasks at scale.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/yb2460/harness-anything/tree/master/cli_anything/wps/skills

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

What does cli-anything-wps do?

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

typePurpose
textText box
imageImage (including matplotlib charts)
tableTable
cards_2x32-row x 3-column colored cards
cards_1x4_info4-column numerical stats cards
card_list_wideTable of contents numbered list
tagline_barPage 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:

ProjectPagesTopic
Tsinghua PUMC/Lanzhou University/Tongji Medical College/Harbin Institute of Technology/Chongqing University/Nanhua University12 pagesUniversity admissions
Sun Yat-sen University/USTC/UCAS15 pagesPrestigious university admissions
Fudan University12 pagesNew engineering + Medical school
SUSTech Cancer Hospital12 pagesJoint Master/PhD program
Peking University/Tsinghua/SUSTech/HUST/Zhejiang University City College9-14 pagesUniversity introductions
# Full execution example
python -c "import zipfile; ..."  # Extract template
python gen_charts.py              # Generate charts
python -c "import json; json.load(open('data.json','r',encoding='utf-8'))"  # Validate JSON
taskkill //F //IM wps.exe //T
python build_xxx.py               # Build PPTX+PDF

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

# Create a document
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

# JSON mode (for Agent use)
cli-anything-wps --json document new --type writer --name "test"

Design Presets

PresetColor SchemeUse Case
academicDeep blue #1A3C8BAcademic defense / Grant applications
consultantDeep blue #003366 + Bright cyanConsulting reports
businessBusiness blue #005294Meeting reports / Courseware
techNear black #0F1423Tech / AI / Data reports

Quality Review (5 Dimensions)

DimensionCheck ItemsThreshold
visualFont hierarchy / Contrast / Whitespace70 points
pedagogyNarrative arc / Prerequisite knowledge75 points
proofreadingSpelling / Terminology / Overflow80 points
parityPPTX/PDF consistency85 points
substanceData accuracy / Citations90 points

Individual skills in this repo

This repo contains 1 individual skill — each has its own dedicated page.

Related Skills