Office Toolkit

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

MIT-0 · Free to use, modify, and redistribute. No attribution required.
0 · 20 · 0 current installs · 0 all-time installs
MIT-0
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
技能旨在读写 Word/Excel/PPT/PDF,并在 SKILL.md 中列出了 python-docx、openpyxl、python-pptx、pypdf、pandoc、LibreOffice、pdftoppm 等依赖,这与其文档处理目的相符. 但 registry/_meta.json 和 metadata.requires.anyBinaries 声明没有列出任何必需二进制,存在信息不一致(SKILL.md 期望系统上有 pandoc/soffice/pdftoppm,但元数据没有反映)。
Instruction Scope
SKILL.md 的具体运行时指令专注于读取/创建/编辑文档,示例包括使用 python 库和在少数情形下通过 subprocess 调用 pandoc/soffice 等。没有指令去读取未声明的凭证或上传到第三方端点。需注意示例中会调用 subprocess.run 和建议以 sudo apt 安装系统包,这会要求对宿主机做变更并有执行外部程序的风险(常见但需谨慎)。
Install Mechanism
技能为 instruction-only(无 install spec、无代码文件),这是低风险形式。但 SKILL.md 明确建议用 pip install 和 sudo apt install 来安装依赖(包括需要 root 权限的包),这些安装步骤并不是自动化在注册表元数据中声明的。无可疑下载 URL 或外部脚本被引用。
Credentials
技能不要求任何环境变量、凭证或配置路径,所需权限仅限于安装与运行处理库/工具(以及可能的 sudo 用于 apt)。没有不相称的凭证或跨服务密钥请求。
Persistence & Privilege
技能没有请求始终启用(always: false)、也没有声明要修改其它技能或系统配置。默认允许代理自主调用(platform 默认),但在本案例中未与广泛凭证或持久化能力结合,风险较低。
Assessment
这项技能本身在功能与所需工具上是自洽的,但在安装前请注意: - SKILL.md 要求系统安装 pandoc、LibreOffice、pdftoppm 等并演示用 subprocess 调用外部命令;这些是正常的文档处理依赖,但会修改系统并可能需要 sudo 权限——在受控或生产环境中先评估是否允许安装、或在隔离环境(容器/虚拟机)中运行。 - 注册表元数据没有列出所需二进制(pandoc/soffice/pdftoppm),这是信息不一致——在安装前确认你能满足 SKILL.md 列出的依赖。 - 技能不会请求密钥或外部终端,但处理来自不可信来源的 Office/PDF 文件本身有风险(嵌入脚本、恶意链接或危险的外部内容)。对不可信文件先进行沙箱化或使用只读提取方法。 - 因为这是 instruction-only,技能不会自动把代码写到磁盘,但代理有能力运行示例中的命令;如果你对代理自行执行系统命令不放心,可在安装或使用前禁用该技能的自动调用或在受限环境中测试。 如果你希望更高确信度:要求拥有者在元数据里准确声明必须的系统二进制,或提供一个可复现的安装脚本和署名来源(例如官方包管理器或发行页链接)。

Like a lobster shell, security has layers — review code before you run it.

Current versionv1.0.0
Download zip
latestvk972t2qq84hmc0yev4tw5hnsy5840rbn

License

MIT-0
Free to use, modify, and redistribute. No attribution required.

Runtime requirements

📄 Clawdis

SKILL.md

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

读取

from pypdf import PdfReader
reader = PdfReader('file.pdf')
print(f'页数: {len(reader.pages)}')
for page in reader.pages:
    print(page.extract_text())

合并

from pypdf import PdfWriter, PdfReader
writer = PdfWriter()
for pdf_file in ['doc1.pdf', 'doc2.pdf']:
    reader = PdfReader(pdf_file)
    for page in reader.pages:
        writer.add_page(page)
with open('merged.pdf', 'wb') as f:
    writer.write(f)

分割

reader = PdfReader('input.pdf')
for i, page in enumerate(reader.pages):
    writer = PdfWriter()
    writer.add_page(page)
    with open(f'page_{i+1}.pdf', 'wb') as f:
        writer.write(f)

旋转

page = reader.pages[0]
page.rotate(90)  # 顺时针90度

依赖安装(当前环境状态)

依赖状态
python-docx✅ 已安装
openpyxl✅ 已安装
python-pptx✅ 已安装
pypdf✅ 已安装
pandoc✅ 已安装
LibreOffice✅ 已安装

Agent Rules

  • 创建文件前先确保目录可写
  • 复杂文档先尝试 python-docx 等库,库无法处理再用 LibreOffice
  • PDF 读取优先用 pypdf,文字提取效果差时用 pandoc
  • Excel 格式化参照财务规范(蓝/黑/绿/红字体 + 黄色背景)
  • LibreOffice 路径:sofficelibreoffice(已安装)
  • 收到文件路径时,先检查文件是否存在:pathlib.Path(path).exists()

Files

2 total
Select a file
Select a file to preview.

Comments

Loading comments…