← 返回 Skills 市场
adtomato

Docx Tool

作者 xiaodouzi · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
101
总下载
0
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install docx-tool
功能描述
使用 python-docx 库创建、读取和修改 Word 文档 (.docx)。支持文本、段落、表格、样式、图片等操作。
使用说明 (SKILL.md)

DOCX 文档操作工具

使用 python-docx 库进行 Word 文档的创建、读取和修改。

前置要求

已安装 python-docx:

pip install python-docx

常用操作

创建新文档

from docx import Document
from docx.shared import Inches, Pt, RGBColor
from docx.enum.text import WD_ALIGN_PARAGRAPH

# 创建新文档
doc = Document()

# 添加标题
doc.add_heading('文档标题', level=1)

# 添加段落
p = doc.add_paragraph('这是一个普通段落。')
p.add_run('这是加粗文字').bold = True
p.add_run(',这是普通文字。')

# 保存文档
doc.save('output.docx')

读取现有文档

from docx import Document

doc = Document('input.docx')

# 读取所有段落文本
for para in doc.paragraphs:
    print(para.text)

# 读取表格
for table in doc.tables:
    for row in table.rows:
        for cell in row.cells:
            print(cell.text)

添加表格

from docx import Document

doc = Document()

# 创建 3x3 表格
table = doc.add_table(rows=3, cols=3)
table.style = 'Light Grid Accent 1'

# 填充表头
hdr_cells = table.rows[0].cells
hdr_cells[0].text = '姓名'
hdr_cells[1].text = '年龄'
hdr_cells[2].text = '城市'

# 填充数据
row_cells = table.rows[1].cells
row_cells[0].text = '张三'
row_cells[1].text = '25'
row_cells[2].text = '北京'

doc.save('table.docx')

设置样式

from docx import Document
from docx.shared import Pt, RGBColor, Inches
from docx.enum.text import WD_ALIGN_PARAGRAPH

doc = Document()

# 添加标题并设置样式
heading = doc.add_heading('标题', level=1)
heading.alignment = WD_ALIGN_PARAGRAPH.CENTER

# 添加段落并设置格式
p = doc.add_paragraph()
run = p.add_run('自定义格式文字')
run.font.size = Pt(14)
run.font.bold = True
run.font.color.rgb = RGBColor(255, 0, 0)

# 设置段落间距
p.paragraph_format.space_before = Pt(12)
p.paragraph_format.space_after = Pt(12)

doc.save('styled.docx')

添加图片

from docx import Document
from docx.shared import Inches

doc = Document()
doc.add_heading('带图片的文档', level=1)

# 添加图片
doc.add_picture('image.png', width=Inches(5.0))

# 添加图片说明
doc.add_paragraph('图 1: 示例图片', style='Caption')

doc.save('with_image.docx')

修改现有文档

from docx import Document

doc = Document('existing.docx')

# 在开头插入段落
doc.paragraphs[0].insert_paragraph_before('新插入的段落')

# 修改现有段落
if doc.paragraphs:
    doc.paragraphs[0].text = '修改后的文字'

# 添加新内容到末尾
doc.add_paragraph('添加到末尾的段落')

doc.save('modified.docx')

可用表格样式

  • Table Grid - 基础网格
  • Light Grid Accent 1 - 浅色网格
  • Medium Grid 1 - 中等网格
  • Medium Grid 2 - 中等网格 2
  • Medium Grid 3 - 中等网格 3

段落对齐方式

  • WD_ALIGN_PARAGRAPH.LEFT - 左对齐
  • WD_ALIGN_PARAGRAPH.CENTER - 居中
  • WD_ALIGN_PARAGRAPH.RIGHT - 右对齐
  • WD_ALIGN_PARAGRAPH.JUSTIFY - 两端对齐

注意事项

  1. 文件格式: 仅支持 .docx 格式,不支持 .doc 格式
  2. 兼容性: 复杂格式在不同 Word 版本间可能有差异
  3. 图片: 支持的格式包括 PNG, JPEG, GIF, BMP
  4. 字体: 使用系统已安装的字体
安全使用建议
This skill is basically a how-to document for python-docx and appears coherent. Before using it: 1) ensure you install python-docx from a trusted source (pip from PyPI) in a controlled environment; 2) be aware the examples read and write local .docx files—do not run the examples against sensitive documents you do not want the agent or execution environment to access; 3) because this is instruction-only, the skill itself doesn’t execute code on install—code will run only if you or an agent actually executes the provided Python snippets. If you plan to let an autonomous agent run these examples, restrict its workspace and review any files it will access.
功能分析
Type: OpenClaw Skill Name: docx-tool Version: 1.0.0 The skill bundle provides standard documentation and code examples for using the legitimate 'python-docx' library to create, read, and modify Word documents. All code snippets in SKILL.md are typical library usage patterns for document manipulation, and there are no indicators of malicious intent, data exfiltration, or prompt injection.
能力评估
Purpose & Capability
Name/description match the SKILL.md examples: all instructions show how to use python-docx to create/read/modify .docx files. There are no unrelated binaries, credentials, or config paths requested.
Instruction Scope
Instructions stay within the stated purpose (file creation, reading, tables, styles, images). They do reference reading and writing local filenames (e.g., 'input.docx', 'existing.docx', 'output.docx') and recommend installing python-docx via pip; this is expected for a docx utility but means the agent or user running these examples will access workspace files—be cautious about sensitive documents.
Install Mechanism
No install spec is included in the skill bundle (instruction-only). The SKILL.md suggests 'pip install python-docx' but the skill does not automatically download or execute anything itself, which is low-risk. Users should install packages from trusted package indexes when running examples.
Credentials
The skill requests no environment variables, credentials, or config paths. That is proportionate to its stated functionality.
Persistence & Privilege
always is false and the skill does not request persistent or elevated platform privileges. It does not modify other skills or system settings.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install docx-tool
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /docx-tool 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of docx-tool. - Provides examples for creating, reading, and modifying Word (.docx) documents using python-docx. - Includes guides for working with text, paragraphs, tables, styles, and images. - Lists available table styles and paragraph alignment options. - Notes on file format support, compatibility, supported image types, and font usage.
元数据
Slug docx-tool
版本 1.0.0
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 1
常见问题

Docx Tool 是什么?

使用 python-docx 库创建、读取和修改 Word 文档 (.docx)。支持文本、段落、表格、样式、图片等操作。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 101 次。

如何安装 Docx Tool?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install docx-tool」即可一键安装,无需额外配置。

Docx Tool 是免费的吗?

是的,Docx Tool 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Docx Tool 支持哪些平台?

Docx Tool 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Docx Tool?

由 xiaodouzi(@adtomato)开发并维护,当前版本 v1.0.0。

💬 留言讨论