---
name: Office Docx Expert
slug: office-docx-expert
category: Automation
description: Office Docx Expert generates Word documents with python-docx, including headings, tables, images, page layout, and formatting rules. Use it when you need programmatic .docx creation with Chinese and English typography conventions.
github: "https://github.com/val1813/kwcode/tree/master/kaiwu/builtin_experts/office_docx"
language: Python
stars: 688
forks: 92
install: "npx degit https://github.com/val1813/kwcode/tree/master/kaiwu/builtin_experts/office_docx ~/.claude/skills/office_docx"
installs_to: ~/.claude/skills/office_docx
source_path: kaiwu/builtin_experts/office_docx/SKILL.md
collection_size: 19
category_size: 1523
collection_url: "https://dirskills.com/collections/val1813/kwcode"
added: 2026-08-12T04:43:49.566Z
last_synced: 2026-08-12T04:43:49.566Z
canonical_url: "https://dirskills.com/skills/office-docx-expert"
---

# Office Docx Expert

Office Docx Expert generates Word documents with python-docx, including headings, tables, images, page layout, and formatting rules. Use it when you need programmatic .docx creation with Chinese and English typography conventions.

**Install:**

```bash
npx degit https://github.com/val1813/kwcode/tree/master/kaiwu/builtin_experts/office_docx ~/.claude/skills/office_docx
```

## README

## 领域知识

- 使用python-docx库生成，Document()创建空文档
- 中文正文字体：宋体/仿宋，标题：微软雅黑/黑体，英文：Times New Roman
- 正文字号：小四（12pt），标题逐级递增（二号→小三→四号）
- 首行缩进：paragraph_format.first_line_indent = Cm(0.74)（两个中文字符）
- 行距：1.5倍行距，paragraph_format.line_spacing = 1.5
- 页边距：上下2.54cm，左右3.17cm（Word默认值）
- 表格：Table(rows, cols)，首行深色背景+白色加粗文字，内容行交替底色
- 页眉页脚：section.header.paragraphs[0] 设置文字，页码用WD_ALIGN_PARAGRAPH.CENTER
- 标题层级：add_heading(text, level=1/2/3)，自动生成目录结构
- 图片插入：add_picture(path, width=Cm(14)) 居中显示
- 保存前不要忘记 document.save(filename)

## 经验规则（自动生成）
