بنقرة واحدة
docx
Word 文档处理。用于读取、写入、编辑、模板填充 .docx 文件。支持页眉页脚、超链接、目录、图片操作。使用 Patcher API 保留原文档样式。当用户需要操作 Word 文档时触发。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Word 文档处理。用于读取、写入、编辑、模板填充 .docx 文件。支持页眉页脚、超链接、目录、图片操作。使用 Patcher API 保留原文档样式。当用户需要操作 Word 文档时触发。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
文件系统操作。⚠️读取前先调用info获取文件信息:图片用read_file(mode='data_url'),大文件用from/lines分块。
PowerPoint 演示文稿处理。用于读取现有 PPTX 基本信息、文本、表格、图表基础数据与备注,创建新演示文稿,并提取媒体文件。支持在新建演示文稿时添加文本、图片、表格、图表、形状、媒体与演讲者备注。当用户提到 .pptx 文件或需要操作 PowerPoint 时触发。
Excel 文件处理。用于读取、写入、编辑 .xlsx/.xls/.csv 文件,支持工作表管理、格式化、公式计算、数据查询和格式转换。当用户需要操作电子表格文件时触发。
发票专用解析技能。支持中国增值税发票、普通发票、电子发票的结构化提取。基于 pdfjs-dist 实现坐标提取,可提取发票号码、日期、买卖双方信息、商品明细、金额等字段。
PDF 文件处理。用于读取、提取文本/表格/图片、合并、拆分、旋转、水印、加密/解密、表单填写、页面渲染。当用户提到 .pdf 文件或需要操作 PDF 时触发。
PDF 文件处理(Python 版)。使用 PyMuPDF 实现,内存效率高,适合处理大文件。用于读取、提取文本/表格/图片、合并、拆分、旋转、水印、加密/解密、页面渲染。当用户提到 .pdf 文件或需要操作 PDF 时触发。
| name | docx |
| description | Word 文档处理。用于读取、写入、编辑、模板填充 .docx 文件。支持页眉页脚、超链接、目录、图片操作。使用 Patcher API 保留原文档样式。当用户需要操作 Word 文档时触发。 |
重要:所有工具的
path参数遵循以下规则(与 FS 技能一致):
- 相对路径直接使用,依赖 VM 设置的工作目录
- 绝对路径不被允许
示例:
// 相对路径(推荐)
read({ path: 'input/document.docx', scope: 'text' })
read({ path: 'data/output.docx', scope: 'text' })
| 工具 | 说明 | 关键参数 |
|---|---|---|
read | 读取文档 | scope: info/text/paragraphs/tables/comments/images/headers/footers |
write | 写入文档 | source: data/markdown,支持 header/footer |
patch | 模板填充 | patches: { placeholder: value },保留原文档样式 |
edit | 编辑文档 | action: replace/append/insert/delete |
convert | 格式转换 | format: markdown/html |
image | 图片操作 | action: extract/insert/list |
link | 超链接操作 | action: add/list |
toc | 目录操作 | action: insert/update |
| scope | 说明 | 返回内容 |
|---|---|---|
info | 文档信息 | 元数据、段落数、字数、是否有页眉页脚 |
text | 提取文本 | 纯文本或 HTML(includeFormatting: true) |
paragraphs | 提取段落 | 段落列表(可选样式) |
tables | 提取表格 | 表格数据数组 |
comments | 提取批注 | 批注列表 |
images | 提取图片信息 | 图片列表(路径、大小) |
headers | 提取页眉 | 页眉内容 |
footers | 提取页脚 | 页脚内容 |
// 读取文档信息
read({ path: 'document.docx', scope: 'info' })
// 返回: { metadata, paragraphCount, characterCount, wordCount, hasHeader, hasFooter }
// 提取文本
read({ path: 'document.docx', scope: 'text' })
read({ path: 'document.docx', scope: 'text', includeFormatting: true }) // 返回 HTML
// 提取段落/表格/批注
read({ path: 'document.docx', scope: 'paragraphs' })
read({ path: 'document.docx', scope: 'tables' })
read({ path: 'document.docx', scope: 'comments' })
// 提取图片信息
read({ path: 'document.docx', scope: 'images' })
// 返回: { imageCount, images: [{ path, fileName, extension, size }] }
// 提取页眉页脚
read({ path: 'document.docx', scope: 'headers' })
read({ path: 'document.docx', scope: 'footers' })
| 参数 | 类型 | 说明 |
|---|---|---|
path | string | 输出文件路径 |
source | string | 数据来源:data 或 markdown |
content | array | 内容数据(source 为 data) |
markdown | string | Markdown 内容(source 为 markdown) |
title | string | 文档标题 |
properties | object | 文档属性(author, subject, keywords) |
header | object | 页眉配置 |
footer | object | 页脚配置 |
sections | array | 多节配置 |
header: {
text: 'Document Header',
alignment: 'CENTER' // LEFT, CENTER, RIGHT
}
footer: {
text: 'Company Name',
pageNumber: true,
pagePrefix: 'Page ',
pageSuffix: '',
pageAlignment: 'CENTER'
}
// 从数据创建(带页眉页脚)
write({
path: 'output.docx',
source: 'data',
title: 'Report Title',
header: { text: 'Company Report', alignment: 'CENTER' },
footer: { pageNumber: true, pagePrefix: 'Page ' },
content: [
{ type: 'heading', text: 'Introduction', level: 1 },
{ type: 'paragraph', text: 'This is the content.' },
{ type: 'paragraph', text: 'Bold text', runs: [{ text: 'Bold', bold: true }] },
{ type: 'list', items: ['Item 1', 'Item 2'] },
{ type: 'table', headers: ['Name', 'Value'], rows: [['A', '1']] }
]
})
// 从 Markdown 创建
write({
path: 'output.docx',
source: 'markdown',
markdown: '# Title\n\nParagraph with **bold** text.\n\n- Item 1\n- Item 2',
header: { text: 'Header' },
footer: { pageNumber: true }
})
// 多节文档
write({
path: 'output.docx',
sections: [
{
content: [{ type: 'heading', text: 'Section 1', level: 1 }],
header: { text: 'Section 1 Header' }
},
{
content: [{ type: 'heading', text: 'Section 2', level: 1 }],
header: { text: 'Section 2 Header' }
}
]
})
重要:使用 Patcher API,保留原文档样式!
| 参数 | 类型 | 说明 |
|---|---|---|
path | string | 模板文件路径 |
patches | object | 替换数据 { placeholder: value } |
output | string | 输出文件路径(可选,默认覆盖原文件) |
keepOriginalStyles | boolean | 保留原文档样式(默认 true) |
delimiters | object | 占位符分隔符(默认 { start: '{{', end: '}}' }) |
在 Word 文档中使用 {{placeholder}} 格式的占位符:
姓名:{{name}}
日期:{{date}}
金额:{{amount}}
// 简单文本替换
patch({
path: 'template.docx',
patches: {
name: '张三',
date: '2024-01-15',
amount: '¥1,000.00'
},
output: 'output.docx'
})
// 复杂替换(段落样式)
patch({
path: 'template.docx',
patches: {
title: {
type: 'paragraph',
children: [{ text: '新标题', bold: true, size: 28 }]
}
}
})
// 自定义分隔符
patch({
path: 'template.docx',
patches: { name: 'John' },
delimiters: { start: '[[', end: ']]' }
})
推荐使用
patch工具进行编辑,可保留原文档样式
| action | 说明 | 关键参数 |
|---|---|---|
replace | 替换占位符 | replacements: { placeholder: value } |
append | 添加段落 | text: 内容 |
insert | 插入段落 | text: 内容,placeholder: 占位符 |
delete | 删除内容 | placeholder: 占位符 |
// 替换占位符(保留格式)
edit({
path: 'document.docx',
action: 'replace',
replacements: {
title: '新标题',
author: '张三'
}
})
// 在占位符处插入内容
edit({
path: 'document.docx',
action: 'insert',
placeholder: 'content_here',
text: '这是新插入的内容'
})
// 添加段落到末尾
edit({
path: 'document.docx',
action: 'append',
text: '新段落'
})
// 删除占位符内容
edit({
path: 'document.docx',
action: 'delete',
placeholder: 'remove_this'
})
// 转 Markdown
convert({ path: 'document.docx', format: 'markdown' })
convert({ path: 'document.docx', format: 'markdown', output: 'document.md' })
// 转 HTML
convert({ path: 'document.docx', format: 'html' })
convert({ path: 'document.docx', format: 'html', output: 'document.html', includeStyles: true })
| action | 说明 | 关键参数 |
|---|---|---|
list | 列出图片 | 无额外参数 |
extract | 提取图片 | outputDir: 输出目录 |
insert | 插入图片 | imagePath: 图片路径,placeholder: 占位符 |
// 列出图片
image({ path: 'document.docx', action: 'list' })
// 提取图片
image({ path: 'document.docx', action: 'extract', outputDir: './images' })
// 在占位符处插入图片(保留格式)
image({
path: 'document.docx',
action: 'insert',
placeholder: 'image_here',
imagePath: 'chart.png',
width: 500,
height: 300
})
// 插入图片到末尾(可能丢失格式)
image({
path: 'document.docx',
action: 'insert',
imagePath: 'chart.png',
width: 500,
height: 300
})
| action | 说明 | 关键参数 |
|---|---|---|
list | 列出超链接 | 无额外参数 |
add | 添加超链接 | placeholder: 占位符,url: 链接,text: 显示文本 |
// 列出超链接
link({ path: 'document.docx', action: 'list' })
// 在占位符处添加超链接
link({
path: 'document.docx',
action: 'add',
placeholder: 'link_here',
url: 'https://example.com',
text: '点击访问'
})
| action | 说明 | 关键参数 |
|---|---|---|
insert | 插入目录 | placeholder: 占位符 |
update | 更新目录提示 | 无额外参数 |
// 在占位符处插入目录
toc({
path: 'document.docx',
action: 'insert',
placeholder: 'toc_here'
})
// 更新目录提示
toc({ path: 'document.docx', action: 'update' })
// 返回提示:需要在 Word 中手动更新目录(F9)
使用 patch 工具进行模板填充,可保留原文档的所有样式:
// 推荐:使用模板填充
patch({ path: 'template.docx', patches: { name: '张三' } })
// 不推荐:直接编辑(可能丢失格式)
edit({ path: 'document.docx', action: 'append', text: '新内容' })
{{customer_name}}、{{invoice_date}}姓名:{{ name }}创建专业文档时添加页眉页脚:
write({
path: 'report.docx',
header: { text: '公司报告', alignment: 'CENTER' },
footer: { pageNumber: true, pagePrefix: '第 ', pageSuffix: ' 页' },
content: [...]
})
patch 工具可保留原文档样式{{placeholder}},可自定义分隔符