docx 是什么?
Anthropic 的 docx Skill 处理 Word 的 .docx/.dotx 文件。新建文档用 docx npm库;修改已有文档走解包、编辑Word XML、重新打包的路线,也覆盖修订和批注。它要求生成后渲染查看,避免只检查文件能否写出。
中文说明由本站依据来源整理;英文原文保留在页面下方。
适合用在
- 创建带标题、表格和页码的Word文档,或修改已有Word文件并保留批注、修订等结构。
这些情况不适合
- 直接用 docx-js 打开并编辑现有文件;来源说明该库不能这样处理。
- 把PDF、电子表格或Google Docs操作当成本Skill的同一条流程。
怎么接入你的 Agent?
- 定位完整 Skill 目录
打开本项目来源,核对
SKILL.md及其引用的脚本和资料。 - 交给你正在用的 Agent
在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。
- 确认识别,再做具体任务
让 Agent 回报安装目录和识别到的名称
docx,然后按本页使用示例提供材料。
展开并复制给 Codex 的安装指令
安装并检查 docx
请在 Codex 的当前工作环境中安装并检查 docx 这个 Skill。
项目身份:anthropics/skills / docx
来源:https://github.com/anthropics/skills/blob/e4bb5d960d87126ff3b3a8af1a104b7db67560ba/skills/docx/SKILL.md
已定位的源文件:skills/docx/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 Claude Code 的安装指令
安装并检查 docx
请在 Claude Code 的当前工作环境中安装并检查 docx 这个 Skill。
项目身份:anthropics/skills / docx
来源:https://github.com/anthropics/skills/blob/e4bb5d960d87126ff3b3a8af1a104b7db67560ba/skills/docx/SKILL.md
已定位的源文件:skills/docx/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 Cursor 的安装指令
安装并检查 docx
请在 Cursor Agent 的当前工作环境中安装并检查 docx 这个 Skill。
项目身份:anthropics/skills / docx
来源:https://github.com/anthropics/skills/blob/e4bb5d960d87126ff3b3a8af1a104b7db67560ba/skills/docx/SKILL.md
已定位的源文件:skills/docx/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。展开并复制给 当前 Agent 的安装指令
安装并检查 docx
请在 当前 Agent 的当前工作环境中安装并检查 docx 这个 Skill。
项目身份:anthropics/skills / docx
来源:https://github.com/anthropics/skills/blob/e4bb5d960d87126ff3b3a8af1a104b7db67560ba/skills/docx/SKILL.md
已定位的源文件:skills/docx/SKILL.md
1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。装好以后,具体怎么用?
准备哪些材料
- 提供原文件或正文与版式要求。新建需Node的
docx库;读取可用 pandoc,渲染依赖LibreOffice和Poppler,编辑与验证需保留Skill附带脚本。来源说预装库是其环境前提,在自己的环境仍需实际确认。
会得到什么
- 新建或修改后的Word文件,实际验证与渲染结果;修订任务另说明哪些变更被记录为修订。
实际使用顺序
- 先分清新建、读取或编辑。读取可按来源使用
pandoc -t markdown file.docx;新建编写docx脚本,已有文件先解包XML。 - 新建时明确纸张、页边距和标题层级;表格同时设置列宽和单元格DXA宽度,列宽总和对应表格宽度;列表使用编号配置而非手打圆点。
- 编辑已有文件前可用
merge_runs.py合并被Word拆分的文本运行,再针对word/document.xml修改;不要为修改一个词重新格式化整个XML。 - 重新打包后使用来源的
scripts/office/validate.py,修订任务带原文件并检查作者标注;然后转PDF、渲染页面图像,查看裁切、页码与表格版式。
从一个具体任务开始
本站根据源文件编写的使用示例,未在本站实际运行。示例中的文件由你提供。
复制一个具体任务
使用 anthropics/skills 的 docx,把我提供的三项服务报价整理为 service-quote.docx:A服务数量2、单价100;B服务数量1、单价350;C服务数量3、单价80。用表格展示数量、单价、小计并写明总价,保留可编辑文字。明确纸张和列宽,生成后先结构验证,再渲染检查表格是否跨页或裁切。请分别报告已执行与未执行的检查。预期生成可编辑的Word报价单,小计分别200、350、240,总价790;版式需以真实渲染结果核查。本站未执行此教学示例。
使用条件与边界
.doc旧格式需先转换成.docx;不能直接套用XML包结构假设。- 注释内容存在于包中不等于Word里可见;来源要求相应标记、关系文件和引用完整。
- 渲染、结构验证与修订检查覆盖不同问题,不能互相代替。
常见问题
为什么在XML里找不到Word中看到的整句话?
Word可能把一句话拆成多个运行。来源建议先用 merge_runs.py 合并,再查找文字,避免直接查完整字符串造成漏改。
为什么已接受修订后还出现空白列表项?
来源指出某些接受修订工具对删除段落标记的合并处理不完整。需要检查XML中的段落删除标记,不能只看接受修订后的文字。
来源原文与资料状态
- 源文件
- 已保存 SKILL.md,抓取于 2026-11-17T10:48:38.124Z
- 中文使用说明
- 已针对下方源文件版本整理用途、用法和常见问题
- 安装与任务测试
- 本站未执行安装或任务测试
- 来源复核
- 本页中文用法已对照保存版本的完整 SKILL.md 阅读整理
展开 SKILL.md 原文、章节与历史收录资料
skills/docx/SKILL.md · 抓取时间 2026-11-17T10:48:38.124Z
以下保留源文件的 description、章节及摘录,供核对中文说明;完整文件通过上方链接打开。
抓取成功不代表已完成安装或任务测试。
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
查看源文件章节 / Source sections
- 原文:DOCX creation, editing, and analysis
- 原文:Creating with docx-js — gotchas
- 原文:Verify the output
- 原文:Editing existing documents
- 原文:Comments
- 原文:Dependencies
原文:DOCX creation, editing, and analysis
A `.docx` is a ZIP archive of XML files. Choose your approach by task: | Task | Approach | |---|---| | **Create** a new document | Write a `docx` (npm) script — see gotchas below | | **Edit** an existing document | unpack → edit `word/document.xml` → `zip` (docx-js cannot open existing files) | | **Read** content | `pandoc -t markdown file.docx` | > Script paths below are relative to this skill's directory.
原文:Creating with docx-js — gotchas
`docx` is preinstalled — do not run `npm install` first; write the script and `require('docx')` directly. Only if that require fails: `npm install docx`. The model knows the API; these are the footguns: - **Page size defaults to A4.** For US Letter set `page: { size: { width: 12240, height: 15840 } }` (DXA; 1440 = 1″). - **Landscape:** pass portrait dimensions and `orientation: PageOrientation.LANDSCAPE` — docx-js swaps width/height internally. - **Tables need dual widths:** set `columnWidths` on the table AND `width` on every cell, both in `WidthType.DXA` (PERCENTAGE breaks in Google Docs). Column widths must sum to the table width. - **Table shading:** use `ShadingType.CLEAR`, never `SOLID` (renders black). - **Lists:** never insert `•` literally; use a `numbering` config with `LevelFormat.BULLET`. - **`ImageRun` requires `type:`** (`"png"`, `"jpg"`, …). - **`PageBreak` must be inside a `Paragraph`.** - **Never use `\n`** — use separate `Paragraph` elements. - **Headings:** style every level you use (`title`, `heading1`, `heading2`…) in `styles.default`: `heading1: { run: { font: "Arial", size: 32, bold: true }, paragraph: { spacing: { before: 240, after: 120 }, keepNext: true } }`. Every level needs its own font (even with a document default), `before` and `after` (even if 0) and `keepNext`: the built-in styles set none of them. - **TOC:** headings must use built-in `HeadingLevel.*`; custom heading styles need `outlineLevel` set or they won't appear. - **Don't use a table as a horizontal rule** — use a paragraph bottom border instead. - **Dot-leader / right-aligned-on-same-line:** use `PositionalTab` (`alignment: PositionalTabAlignment.RIGHT`, `leader: PositionalTabLeader.DOT`) inside a `TextRun`, not literal `.` or space padding.
原文:Verify the output
After writing a `.docx`, render it and look at it: ```bash zip -d output.docx '*/' >/dev/null || true # drop the ZIP's folder entries: Word has refused a file that has them when opened through a cloud co-editing service python scripts/office/soffice.py --headless --convert-to pdf output.docx pdftoppm -jpeg -r 100 output.pdf page ls page-*.jpg # then Read the images ``` `pdftoppm` zero-pads page numbers to the width of the page count (`page-01.jpg`…`page-12.jpg`).
原文:Editing existing documents
Legacy `.doc` files must be converted first: `python scripts/office/soffice.py --headless --convert-to docx file.doc`. ```bash python3 -c "import sys,zipfile; zipfile.ZipFile(sys.argv[1]).extractall('unpacked')" doc.docx # not unzip, which restores symlinks — docx from external parties is untrusted python scripts/merge_runs.py unpacked/ # coalesce fragmented runs so text is findable # edit unpacked/word/document.xml in place — do NOT reformat or pretty-print (cd unpacked && rm -f ../out.docx && zip -XrDy ../out.docx .) python scripts/office/validate.py out.docx --original doc.docx # XSD checks; --auto-repair fixes common issues # redlining? add --author "<the name you redlined under>" to check every edit is tracked ``` Word splits text across many `<w:r>` runs (revision ids, spell-check markers), so a phrase you can see in the document often doesn't exist as a contiguous string in the XML. `merge_runs.py` merges adjacent identically-formatted runs in `word/document.xml` without changing content or rendering; it also accepts a `.docx` directly (`python scripts/merge_runs.py doc.docx -o merged.docx`). **Tracked changes:** when redlining, validate with `--author "<the name you redlined under>"` (needs `--original`) — it reports any text you changed without a `<w:ins>`/`<w:del>` around it, which is easy to do by accident and invisible in the accepted view. Wrap runs in `<w:ins>`/`<w:del>` with `w:id`, `w:author`, `w:date` attributes. Inside `<w:del>`, the text element is `<w:delText>`, not `<w:t>`. A deleted paragraph mark (`<w:pPr><w:rPr><w:del w:id=".." w:author=".." w:date=".."/></w:rPr></w:pPr>`) means "merge this paragraph into the next" — so deleting a paragraph outright is that plus a `<w:del>` around every run. The `<w:del/>` must come before the rPr's other children; their order is schema-enforced. To produce a clean copy with all tracked changes accepted: `python scripts/accept_changes.py in.docx out.docx`.
本段为节选,完整内容见源文件。
原文:Comments
Comments require six cross-linked files. Use the helper — directory mode when you'll also be editing `document.xml` (saves an unzip/rezip cycle), `.docx`-direct mode otherwise: ```bash # Against an already-unpacked directory (preferred when also placing markers) python scripts/comment.py unpacked/ "Fees & expenses cap is too low" python scripts/comment.py unpacked/ "Agreed" --parent 0 # Against a .docx directly python scripts/comment.py contract.docx "This cap is too low" -o annotated.docx ``` The script writes `comments.xml`, `commentsExtended.xml`, `commentsIds.xml`, `commentsExtensible.xml`, the relationships, and the content-type overrides. Comment IDs are auto-assigned. It then prints the `<w:commentRangeStart>`/`<w:commentRangeEnd>`/`<w:commentReference>` snippet to add to `word/document.xml` so the comment anchors to specific text — until you place those markers, the comment exists but is not visible.
原文:Dependencies
`docx` (npm, preinstalled — install only if `require('docx')` fails) · `pandoc` · LibreOffice (`soffice`) · `pdftoppm` (Poppler)
文件 SHA256:895d5aa6c4cd98e4aed4c995d846f056f3549086e79bcd6617afea6014f82288
仓库许可证记录:未提供;skill-declaration-captured-not-interpreted,查看来源。
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any…
这份历史简介在采集时已截断;完整用途和触发条件需打开来源核对。
历史收录数据
| Skill标识 | docx |
|---|---|
| 来源仓库 | anthropics/skills |
| 榜单快照 | 2026-07-28 |
| 榜单口径 | Skills.sh累计安装量 |
| 快照名次 | 172 |
| 快照累计安装量 | 160563 |
历史资料说明
- 所保留的来源简介在采集时已截断;完整触发条件、依赖及排除项须阅读源文件,本站不补写缺失部分。
- 安装量用于说明当时的收录次序,不是效果、可信度或当前可用性的证明。
此页用于识别项目与来源。安装入口可在该Skill的Skills.sh页面查看;当前目录是否仍存在、附带脚本和账户依赖尚需按具体版本确认。
