AgentStack
SKILL verified MIT Self-run

Docx Cn

skill-ssssliug-claude-skill-docx-cn-claude-skill-docx-cn · by ssssliug

生成 .docx(docx-js)——Node 实现、中文优先、研究汇报向。内置 Node 运行法 / 共享依赖 NODE_PATH 技巧、中文字体坑、navy 学术配色、结果表(Rel/Gen/Loc/Avg 最佳值标红)模板、以及 Word 排版踩坑(标题/表格/列表/右对齐点引导符/分页/图片)。触发:做 Word / 报告 / 文档 / .docx,尤其涉及中文、实验结果表、指标、中英混排。

No reviews yet
0 installs
0 views
view→install

Install

$ agentstack add skill-ssssliug-claude-skill-docx-cn-claude-skill-docx-cn

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access Used
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Docx Cn? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Word 文档生成(Node · 中文 · 研究向)

面向 Node-only 环境(无 Python / LibreOffice / pandoc,在 Windows + Node v24 上验证过;macOS / Linux 同理)。.docxdocx(npm 包名 docx,即 docx-js)。只做创建——转 PDF / 缩略图 / schema 校验等 QA 本机跑不了(要视觉预览需另装 LibreOffice)。

官方 ~/.claude/skills/docx(默认停用,文件仍在)有更全的踩坑表与 Python 脚本(校验 / 缩略图 / 模板编辑 / tracked changes / comments)。遇到复杂或排错场景,可手动 cat ~/.claude/skills/docx/SKILL.md 当字典查——它不自动加载,但内容在。配套 PPT 技能见 pptx-cn

运行(两种方式任选)

方式 A · 本仓库装依赖(推荐,跨平台):仓库根 package.json 已列好依赖,npm install 后直接跑:

npm install
node templates/results_docx.js out.docx   # 输出路径可中文

方式 B · 共享依赖 + NODEPATH(Windows / Git Bash 特有技巧):把所有 skill 的 nodemodules 集中放一处(如 ~/.claude/skills-deps/node_modules,含 docx),脚本里直接 require()、不必每个仓库各装一份。node 是原生 Windows 程序、不认 MSYS 的 ~ / /tmp 路径,必须 cygpath + NODE_PATH:

NODE_PATH=$(cygpath -w ~/.claude/skills-deps/node_modules) node 脚本.js

输出用完整 Windows 路径 C:/.../名.docx,中文路径 OK。


Word (docx-js)

const {Document,Packer,Paragraph,TextRun,HeadingLevel,Table,TableRow,TableCell,WidthType,ShadingType,AlignmentType,PageOrientation,PositionalTab,PositionalTabAlignment,PositionalTabLeader} = require('docx');
  • 页面默认 A4;US Letter:page:{size:{width:12240,height:15840}}(DXA,1440=1″);横屏传纵向尺寸 + orientation:PageOrientation.LANDSCAPE
  • 中文:每个 TextRun 都带 font:'Microsoft YaHei',否则默认 Calibri 掉中文;省事可在 styles.default.document.run.font 设一次默认字体、单处再覆盖。
  • 标题用 HeadingLevel.HEADING_1/2(目录依赖它;自定义样式需设 outlineLevel)。
  • 表格:表级 columnWidths + 每格 width(DXA) 都要设(PERCENTAGE 在 Google Docs 会坏);列宽之和等于表宽。底纹用 ShadingType.CLEAR别用 SOLID(渲染成黑)。
  • 列表用 numberingLevelFormat.BULLET,别手敲
  • ImageRun 必须带 type:"png" / "jpg" …)。
  • 别用 \n,用多个 ParagraphPageBreak 必须包在 Paragraph 里。
  • 同行右对齐 + 点引导符:用 PositionalTabalignment:PositionalTabAlignment.RIGHTleader:PositionalTabLeader.DOT),别手敲 . 或空格补。
  • 输出:Packer.toBuffer(doc).then(b => fs.writeFileSync('out.docx', b))

结果表(每列最佳值标红)

研究汇报关键是每列最佳值加粗标红。别手敲——见 templates/results_docx.js:先 num.forEach(k => best[k] = Math.max(...rows.map(r => r[k]))) 找每列 max,再在生成单元格时 isBest = Math.abs(r[k]-best[k]) < 1e-6 决定 bold + color。表头底纹用 navy 1F3A5F 配白字,自己方法那行用浅底 F4F6F7 高亮。

模板:templates/results_docx.js(标题 + 段落 + 结果表,最佳值标红)。

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.