Skills

Office File Process

处理 Office 文档的一站式...

Install

npx skills add xstongxue/best-skills --skill office-file-process -g -a claude-code -y
Repository
xstongxue/best-skills3.1k
Category
Documents
Updated
2mo ago
License
Apache-2.0
Context cost
Mediumabout 1,698 tokens
Runs scripts
Yes, review before use

What it does

处理 Office 文档的一站式 skill:Word(.doc/.docx/.dotx)、Excel(.xls/.xlsx/.xlsm/.csv)、PowerPoint(.ppt/.pptx/.potx) 的创建、读取、编辑、提取、转换、校验。触发:『读取 word 文档』『提取 excel 内容』『看 ppt 讲了什么』、.doc 老格式打不开、生成/编辑 Word 报告/合同/模板、制作幻灯片/deck/演示文稿、写带公式的电子表格。读取优先 pandoc/markitdown 等官方工具,环境没有则走 Windows Office COM 自动化(含中文文件名、PowerShell 编码等 Windows 环境方案);创建/编辑用 docx-js、pptxgenjs、openpyxl 等。Use whenever any .docx/.xlsx/.pptx file is the primary input or output: create, read, edit, extract, convert, or validate it.

Office 文档处理(统一入口)

处理 Word / Excel / PowerPoint 文件的统一 skill。面向 Windows + Office 环境(COM 自动化是它独有的兜底能力),不预设任何机器装了哪些工具, , 动手前先探测环境,再按本文规则决策。非 Windows 或无 Office 的机器见文末降级方案。先按任务路由,细节在对应参考文档里。

任务路由

任务路线详情
读取/提取任何 Office 文档内容按下方"读取路线怎么选"决策本页
创建/编辑 Word 文档docx-js(新建)/ unzip+XML(编辑)reference/docx.md
创建/编辑 PowerPointpptxgenjs(新建)/ unzip+XML(编辑)reference/pptx.md
创建/编辑 Excelopenpyxl / pandasreference/xlsx.md
校验 docx/pptx/xlsx 输出scripts/office/validate.py各格式参考文档的 QA 节

读取路线怎么选(官方工具 vs Office COM)

原则:有环境就用官方的(输出质量更高),没有就用 COM 提取脚本。 先探测环境再动手:

where pandoc 2>/dev/null && echo HAS_PANDOC
python -c "import markitdown" 2>/dev/null && echo HAS_MARKITDOWN
python -c "import openpyxl" 2>/dev/null && echo HAS_OPENPYXL
格式环境在(优先)环境不在(退回 COM)
.docxpandoc -t markdown file.docx, 输出带结构 markdown(标题层级、列表、表格),后续处理质量最高extract_office_text.ps1, 纯文本,表格转制表符
.pptxmarkitdown deck.pptx, 每页一块带 <!-- Slide number: N --> 标记extract_office_text.ps1, 逐页文本 + [NOTES] 备注
.xlsxmarkitdown file.xlsx 快速浏览;openpyxl/pandas 精确读(有单元格坐标,规划编辑必须用它)extract_office_text.ps1, 逐 sheet 制表符纯文本,无坐标
.doc/.xls/.ppt(老格式)官方工具也读不了(二进制)COM 是唯一路径(或 COM 转新格式后再走官方工具)

补充判断:

  • openpyxl/pandas 是 pip 一装就有的轻依赖(无需管理员),读 xlsx 需要坐标或要进一步算数据时,直接 pip install openpyxl pandas 比退回 COM 更好;markitdown 其实也是 pip 可装的轻依赖(pip install "markitdown[pptx,xlsx]");只有 pandoc/soffice 是系统级安装,不方便现装。
  • 带保护壳的文档(加密狗水印壳等):一律 COM 对象模型直取 Content.Text, , 已验证 Word SaveAs 导出此类文档是乱码;官方工具(pandoc 等)未在此场景验证过,别拿它冒险。
  • 中文文件名:官方工具能处理,但如果 Read/Grep 打不开输出文件,退回 COM 脚本(输出固定 ASCII 文件名 office_extract_<n>.txt)。
Read the whole SKILL.md on GitHub

More in Documents