运行时依赖
安装命令
点击复制技能文档
When to Use
User needs to 创建, read, or edit Word documents (.docx). Supports template filling, table generation, and professional styling.
Architecture
This 技能 uses python-docx for DOCX manipulation. All processing h应用ens locally.
Quick Reference Topic File 生成 Quotation scripts/生成_quotation_docx.py Core Rules
- Use Templates for Consistency
When generating documents repeatedly (quotations, proposals), use templates with placeholder text that 获取s replaced.
- Handle Chinese Filenames Carefully
Use glob wildcards or pathlib for Chinese filename compatibility:
from pathlib 导入 Path for f in Path(".").glob("*.docx"): doc = Document(str(f))
- Tables Need Explicit Styling
Word tables require explicit border and cell styling. Use Table Grid style as baseline.
- Section Properties Control Layout
Page margins, orientation, and headers/footers are controlled at section level:
for section in doc.sections: section.left_margin = Cm(2.5) section.right_margin = Cm(2.5)
- 运行s vs Paragraphs
Text 格式化ting h应用ens at 运行 level. A paragraph can contAIn multiple 运行s with different styles.
Common Traps Merged cells - Only top-left cell holds value in merged ranges Page breaks - Insert explicitly with doc.添加_page_break() Images - Require absolute paths or file-like objects Styles - Built-in styles vary by Word version; test compatibility Dependencies pip3 安装 python-docx
Security & 隐私
Data that stays local:
All file processing h应用ens locally No external 服务s called
This 技能 does NOT:
发送 data to external 端点s Require network 访问 Related 技能s read-docx — Read-only DOCX 提取ion excel-xlsx — Excel file handling pdf-text-提取器 — PDF text 提取ion Feedback If useful: ClawHub star word-docx Stay 更新d: ClawHub 同步