Office Toolkit
Comprehensive document processing toolkit for Office and PDF files.
ClawHub: https://clawhub.ai/weiwei2027/office-toolkit
Install: INLINECODE0
Supported Formats
| Format | Read | Write | Convert From | Convert To |
|---|
| DOCX | ✅ | ✅ | - | PDF |
| PPTX |
✅ | ✅ | - | PDF |
| XLSX | ✅ | ✅ | - | - |
| PDF | ✅ | ✅ (from DOCX/PPTX) | DOCX, PPTX | - |
Quick Start
Read Documents
CODEBLOCK0
Create Documents
CODEBLOCK1
Convert Formats
CODEBLOCK2
Installation
CODEBLOCK3
Directory Structure
CODEBLOCK4
Python API Usage
CODEBLOCK5
Notes
- - DOCX: Uses
python-docx library. Supports text, tables, styles, images. - PPTX: Uses
python-pptx library. Supports slides, text, shapes, charts. - XLSX: Uses
openpyxl library. Supports cells, formulas, charts, styling. - PDF: Uses
pymupdf (fitz) for reading, reportlab for creation.
Roadmap
- - [x] Excel support (xlsx read/write) - ✅ Added in v1.0.1
- [ ] PDF creation from scratch
- [ ] Format conversion improvements
- [ ] Batch processing
- [ ] Template system
Changelog
v1.0.1 (2026-03-20)
- - Added Excel (.xlsx) read/write support
- Improved error handling with helpful messages
- Added JSON output option for read operations
- Added PDF page selection support
v1.0.0 (2026-03-20)
- - Initial release
- DOCX/PPTX/PDF read and write support
Office Toolkit
适用于 Office 和 PDF 文件的综合文档处理工具包。
ClawHub: https://clawhub.ai/weiwei2027/office-toolkit
安装: clawhub install office-toolkit
支持的格式
| 格式 | 读取 | 写入 | 转换来源 | 转换目标 |
|---|
| DOCX | ✅ | ✅ | - | PDF |
| PPTX |
✅ | ✅ | - | PDF |
| XLSX | ✅ | ✅ | - | - |
| PDF | ✅ | ✅ (来自 DOCX/PPTX) | DOCX, PPTX | - |
快速开始
读取文档
bash
Word
docx-read.py document.docx
PowerPoint
pptx-read.py presentation.pptx
Excel
xlsx-read.py spreadsheet.xlsx
PDF
pdf-read.py document.pdf
创建文档
bash
带内容的 Word
docx-write.py output.docx --title 报告 --content Hello World
带幻灯片的 PowerPoint
pptx-write.py output.pptx --title 演示文稿 --slides 5
带数据的 Excel
xlsx-write.py output.xlsx --sheet 数据 --data data.json
格式转换
bash
DOCX 转 PDF
convert.py document.docx --to pdf
PPTX 转 PDF
convert.py presentation.pptx --to pdf
安装
bash
安装所有依赖
pip install -r requirements/all.txt
或仅安装所需部分
pip install -r requirements/docx.txt # 仅 Word
pip install -r requirements/pptx.txt # 仅 PowerPoint
pip install -r requirements/xlsx.txt # 仅 Excel
pip install -r requirements/pdf.txt # 仅 PDF
目录结构
office-toolkit/
├── SKILL.md # 本文件
├── requirements/ # 依赖文件
│ ├── base.txt # 核心依赖
│ ├── docx.txt # python-docx
│ ├── pptx.txt # python-pptx
│ ├── xlsx.txt # openpyxl
│ └── pdf.txt # pymupdf
├── scripts/ # CLI 工具
│ ├── docx-read.py
│ ├── docx-write.py
│ ├── pptx-read.py
│ ├── pptx-write.py
│ ├── xlsx-read.py
│ ├── xlsx-write.py
│ ├── pdf-read.py
│ ├── pdf-write.py
│ └── convert.py
├── lib/ # 共享库
│ ├── init.py
│ ├── base.py # 基类
│ ├── utils.py # 工具函数
│ └── validators.py # 输入验证
└── tests/ # 测试套件
├── test_docx.py
├── test_pptx.py
├── test_xlsx.py
└── test_pdf.py
Python API 使用
python
from lib.base import DocumentProcessor
处理 Word 文档
processor = DocumentProcessor(docx)
text = processor.read(document.docx)
processor.write(output.docx, content=新内容)
格式转换
processor.convert(document.docx, pdf)
注意事项
- - DOCX: 使用 python-docx 库。支持文本、表格、样式、图片。
- PPTX: 使用 python-pptx 库。支持幻灯片、文本、形状、图表。
- XLSX: 使用 openpyxl 库。支持单元格、公式、图表、样式。
- PDF: 使用 pymupdf (fitz) 进行读取,reportlab 进行创建。
路线图
- - [x] Excel 支持 (xlsx 读写) - ✅ 已在 v1.0.1 中添加
- [ ] 从零创建 PDF
- [ ] 格式转换改进
- [ ] 批量处理
- [ ] 模板系统
更新日志
v1.0.1 (2026-03-20)
- - 添加了 Excel (.xlsx) 读写支持
- 改进了错误处理,提供更友好的提示信息
- 为读取操作添加了 JSON 输出选项
- 添加了 PDF 页面选择支持
v1.0.0 (2026-03-20)
- - 初始版本发布
- 支持 DOCX/PPTX/PDF 的读写