ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified

office-toolkit

处理 Office 文档(Word/Excel/PPT/PDF)的技能。当用户要求读取、创建、编辑 Word 文档(.docx)、Excel 表格(.xlsx/.csv)、PPT(.pptx)或 PDF 时使用。基于 python-docx、openpyxl、python-pptx、pypdf 库。Requires: python-docx, openpyxl, python-pptx, pypdf, pandoc, LibreOffice(验证用)。

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/axelhu/openclaw-office-toolkit
Or

office-toolkit

处理 Office 文档:Word(.docx)、Excel(.xlsx/.csv)、PPT(.pptx)、PDF。

环境要求

pip install --break-system-packages python-docx openpyxl python-pptx pypdf
sudo apt install libreoffice-writer libreoffice-calc libreoffice-impress pandoc

快速参考

任务库/命令
读 Wordpython-docxpandoc -t markdown
创建/编辑 Wordpython-docx
读 Excelopenpyxlpandas
创建/编辑 Excelopenpyxl
读 PPTpython-pptx
创建/编辑 PPTpython-pptx
读 PDFpypdfpandoc
PDF 格式验证LibreOffice soffice
PDF 转图片pdftoppm (poppler-utils)

Word (.docx)

读取

from docx import Document
doc = Document('file.docx')
for para in doc.paragraphs:
    print(para.text)

# 带格式提取
import subprocess
result = subprocess.run(['pandoc', '--track-changes=all', 'file.docx', '-t', 'markdown'], 
    capture_output=True, text=True)
print(result.stdout)

创建

from docx import Document
from docx.shared import Pt, Inches

doc = Document()
# 标题
doc.add_heading('文档标题', 0)

# 段落
p = doc.add_paragraph('正文内容')
p.runs[0].bold = True  # 加粗
p.runs[0].font.size = Pt(12)
p.runs[0].font.name = 'Arial'

# 引用
doc.add_paragraph('引用内容', style='Intense Quote')

# 表格
table = doc.add_table(rows=2, cols=3)
table.style = 'Light Grid Accent 1'
table.rows[0].cells[0].text = '表头1'
table.rows[0].cells[1].text = '表头2'

doc.save('output.docx')

编辑现有文档

  1. 解压 → 修改 XML → 重新打包(推荐用 python-docx 直接修改)
  2. 复杂格式建议用 LibreOffice 打开编辑

Excel (.xlsx)

读取

import openpyxl
wb = openpyxl.load_workbook('file.xlsx')
ws = wb.active
for row in ws.iter_rows(values_only=True):
    print(row)

创建/编辑

import openpyxl
from openpyxl.styles import Font, PatternFill, Alignment

wb = openpyxl.Workbook()
ws = wb.active
ws.title = '数据'

# 写入
ws['A1'] = '姓名'
ws['B1'] = '年龄'
ws['A2'] = '张三'
ws['B2'] = 25

# 格式化
header_fill = PatternFill(start_color='4472C4', end_color='4472C4', fill_type='solid')
ws['A1'].fill = header_fill
ws['A1'].font = Font(color='FFFFFF', bold=True)
ws['A1'].alignment = Alignment(horizontal='center')

# 保存
wb.save('output.xlsx')

格式化规则(财务场景)

  • 蓝色字体:硬编码输入值
  • 黑色字体:公式/计算
  • 绿色字体:同文件内链接
  • 红色字体:外部链接
  • 黄色背景:需要关注的假设

PowerPoint (.pptx)

读取

from pptx import Presentation
prs = Presentation('file.pptx')
for slide in prs.slides:
    for shape in slide.shapes:
        if hasattr(shape, 'text'):
            print(shape.text)

创建

from pptx import Presentation
from pptx.util import Inches, Pt

prs = Presentation()
prs.slide_width = Inches(10)
prs.slide_height = Inches(7.5)

# 使用空白布局
slide = prs.slides.add_slide(prs.slide_layouts[6])
title = slide.shapes.title
subtitle = slide.placeholders[1]
title.text = '演示标题'
subtitle.text = '副标题'

prs.save('output.pptx')

设计原则

  • 颜色方案:选一个大胆的配色,主色占60-70%,1-2个辅助色,1个尖锐强调色
  • 不要默认蓝色:根据主题选配色
  • 深浅对比:标题页用深色背景,结论页用浅色背景("三明治"结构)
  • 排版留白:不要堆满,留呼吸空间

PDF

Metadata

Author@axelhu
Stars4473
Views0
Updated2026-05-01
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-axelhu-openclaw-office-toolkit": {
      "enabled": true,
      "auto_update": true
    }
  }
}
Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.