办公文档处理_office-documents
以下为本文档的中文说明这是一个全面的办公文档处理技能支持 PDF、WordDOCX、ExcelXLSX/XLSM和 PowerPointPPTX四种常见办公文档格式的读取和编辑操作。它不依赖于 Microsoft Office 或 WPS 等商业软件而是通过开源 Python 库和直接 OOXML 解析来实现文档处理。核心工作流程严格遵循先读后改的原则首先通过 check_env.mjs 预检脚本检查环境是否满足特定操作所需的依赖然后使用 read_document.py 读取文档内容编辑时通过 JSON 操作文件指定要执行的操作序列最后重新读取输出文件验证变更是否正确。支持的编辑操作非常丰富DOCX 支持文本替换、追加段落和添加表格XLSX 支持单元格赋值、公式设置、追加行、添加/重命名工作表以及样式设置PPTX 支持文本替换、指定形状文本设置和文本框添加PDF 支持页面旋转、页面提取、页面删除、文件合并和元数据设置。使用场景包括自动化办公流程中的数据提取、批量生成报告、合同模板填充、数据分析结果导出等。该技能特别注重安全性——所有的编辑操作都保存到新文件而非覆盖原文件文档处理通过确定性脚本而非 AI 猜测操作确保了结果的可重复性和可靠性。Office DocumentsUse this skill for document files, not for building an Office viewer. The goal is to let the agent understand and safely modify files through deterministic scripts.Supported formats:PDF:.pdfWord:.docxExcel:.xlsx,.xlsmPowerPoint:.pptxDo not use Anthropic/Claude document skills as source material. This skill is independently written and relies on permissive open-source libraries or direct OOXML parsing. Seereferences/licenses.mdbefore changing dependencies.Core WorkflowIdentify the file type from the extension and the user’s requested outcome.Read first, edit second. Always inspect the source file before modifying it.Runscripts/check_env.mjsfor the exact capability before any Python worker script.For reading, runscripts/read_document.py.For edits, write a small JSON operations file and run the matching edit script.Save edits to a new output file unless the user explicitly asks to overwrite.Read the output file again withscripts/read_document.pyand verify the requested change.If the requested operation is outside the supported surface, say so clearly and stop.Environment PreflightRun the bundled Node preflight before invoking Python:nodeskills2set/office-documents/scripts/check_env.mjs--capabilityread-docxnodeskills2set/office-documents/scripts/check_env.mjs--capabilityread-pdfnodeskills2set/office-documents/scripts/check_env.mjs--capabilityedit-xlsxBehavior:The preflight itself is JavaScript and uses only Node built-ins.It finds Python throughHANA_OFFICE_PYTHON,python3,python, or Windowspy -3.It requires Python 3.10 because the bundled worker scripts use modern Python syntax.It checks only the packages needed for the requested capability.If it returnsok: false, stop and show the user themessageandinstallGuidance. Do not auto-install dependencies.Capabilities:TaskPreflight capabilityRead DOCXread-docxRead XLSX / XLSMread-xlsxRead PPTXread-pptxRead PDFread-pdfRequire MarkItDown specificallyenhanced-readDOCXreplace_textedit-docx-basicDOCXappend_paragraph/add_tableedit-docx-richXLSX / XLSM editsedit-xlsxPPTXreplace_textedit-pptx-basicPPTXset_shape_text/add_textboxedit-pptx-richPDF structural editsedit-pdfReadingUseread_document.pyfor every supported format:python3 skills2set/office-documents/scripts/read_document.py input.docx--formatmarkdown python3 skills2set/office-documents/scripts/read_document.py input.xlsx--formatjson--outputsummary.json python3 skills2set/office-documents/scripts/read_document.py input.pdf --max-chars120000Behavior:It tries MarkItDown first when available.If MarkItDown is unavailable, it uses direct OOXML readers for DOCX, XLSX, and PPTX.For PDF text extraction it tries pdfplumber, then pypdf.It returns clear JSON errors when required PDF libraries are unavailable or the file is unsupported.For large documents, read enough to understand structure first, then narrow by sheet, slide, page, heading, or searched text.EditingUse JSON operations. Keep each operation explicit and small enough to verify.DOCXpython3 skills2set/office-documents/scripts/edit_docx.py input.docx output.docx--opsops.jsonSupported operations:[{op:replace_text,find:old text,replace:new text},{op:append_paragraph,text:New paragraph},{op:add_table,rows:[[Name,Value],[A,10]]}]Usereplace_textfor safe text updates.append_paragraphandadd_tablerequirepython-docx.XLSXpython3 skills2set/office-documents/scripts/edit_xlsx.py input.xlsx output.xlsx--opsops.jsonSupported operations:[{op:set_cell,sheet:Sheet1,cell:B2,value:Approved},{op:set_formula,sheet:Sheet1,cell:C10, formula: SUM(C2:C9)},{op:append_row,sheet:Sheet1,values:[Total,1200]},{op:add_sheet,name:Summary},{op:rename_sheet,sheet:Sheet1,name:Data},{op:set_style,sheet:Data,cell:A1,bold:true,font_color:FFFFFF,fill_color:1F4E79}]XLSX editing requiresopenpyxl. Preserve formulas unless the user asks to replace them.PPTXpython3 skills2set/office-documents/scripts/edit_pptx.py input.pptx output.pptx--opsops.jsonSupported operations:[{op:replace_text,find:Q1,replace:Q2},{op:set_shape_text,slide:1,shape_index:2,text:Updated title},{op:add_textbox,slide:3,text:Speaker note,left:1,top:1,width:8,height:1}]Usereplace_textfor direct OOXML text updates. Shape targeting and text boxes requirepython-pptx.PDFpython3 skills2set/office-documents/scripts/edit_pdf.py input.pdf output.pdf--opsops.jsonSupported operations:[{op:rotate_pages,pages:1,3-4,degrees:90},{op:extract_pages,pages:1-2,5},{op:delete_pages,pages:7},{op:merge,inputs:[a.pdf,b.pdf]},{op:set_metadata,metadata:{/Title:Updated document}}]PDF editing requirespypdf. Do not claim support for arbitrary PDF text replacement. PDF text is drawing instructions, not normal document text.VerificationAfter any edit:Confirm the output file exists and is non-empty.Read the output withread_document.py.Check that requested content changed and unrelated content still appears intact.Report any limitation, dependency failure, or partial edit.For XLSX formulas, openpyxl preserves formulas but does not calculate them. If calculated values matter and no recalculation engine is available, say that formulas were written but not recalculated locally.Unsupported Or Caution CasesBe explicit when the requested task needs a real Office renderer or advanced document engine:Pixel-perfect layout repair.Scanned PDF OCR when no OCR engine or model is available.PDF arbitrary text replacement.Macros, VBA, encrypted files, password-protected files.Complex PowerPoint animations, transitions, SmartArt, embedded media, OLE objects.Excel pivot table authoring, slicers, external links, macros.Redline or track-changes fidelity matching Microsoft Word.If the user needs one of these, explain the specific limitation and suggest the smallest safe alternative.ReferencesRead only the relevant reference file when needed:references/docx.mdfor Word details.references/xlsx.mdfor spreadsheet details.references/pptx.mdfor PowerPoint details.references/pdf.mdfor PDF details.references/licenses.mdfor licensing and dependency constraints.

相关新闻

后备命令处理_add-fallback-commands

后备命令处理_add-fallback-commands

以下为本文档的中文说明 该技能指导开发者如何为VS Code命令面板(Command Palette)扩展添加后备命令功能,实现全面搜索行为。当用户在命令面板中输入的查询无法匹配任何顶层命令时,后备命令会被触发,使扩展能充当全面处…

2026/7/21 23:21:04阅读更多 →
一文读懂汽车CAN总线 —— 从原理到故障诊断

一文读懂汽车CAN总线 —— 从原理到故障诊断

一、CAN总线是什么CAN(Controller Area Network,控制器局域网)是一种串行通信总线标准,最初由德国BOSCH公司于1980年代开发,用于解决汽车内部电子控制单元(ECU)之间的数据交换问题。在CAN出现之…

2026/7/21 23:19:02阅读更多 →
企业AI知识库:八大行业如何落地?

企业AI知识库:八大行业如何落地?

企业AI知识库:八大行业如何落地? 当你的公司有几千份文档,员工找个资料要翻半小时,你会怎么做?买个大模型把所有文件喂进去?先别急——如果你的文件里有客户的银行流水、患者的病历、核心工艺的配方参数&a…

2026/7/21 23:19:02阅读更多 →
深入解析eQEP模块:从正交编码器原理到高精度位置速度测量实践

深入解析eQEP模块:从正交编码器原理到高精度位置速度测量实践

1. 项目概述与核心价值在伺服电机、机器人关节、数控机床这类需要精确控制旋转或直线位移的嵌入式系统中,如何实时、准确地获取执行机构的位置和速度,是决定整个系统性能上限的关键。这就像给一个盲人装上眼睛,他才能知道自己在哪&#xff0c…

2026/7/22 1:53:59阅读更多 →
Windows下C/C++连接MySQL数据库实战指南

Windows下C/C++连接MySQL数据库实战指南

1. Windows环境下C/C连接MySQL数据库的核心思路在Windows平台上用C/C连接MySQL数据库,本质上是通过MySQL提供的C API与数据库服务建立通信通道。这个过程涉及到几个关键组件:MySQL客户端库(libmysql.dll)、头文件(mysq…

2026/7/22 1:53:59阅读更多 →
大学生学 AI,第一步应该学什么?

大学生学 AI,第一步应该学什么?

当下人工智能已经渗透校园学习、实习求职、专业创作全场景,中国青年报社面向 1032 名大学生的调研显示,99.2% 的在校生日常使用 AI 工具,但 29.84% 的学生仅会基础对话,缺乏系统学习路径,只会用 AI 应付作业&#xff0…

2026/7/22 1:53:59阅读更多 →
USB Fuzzer — 基于 Raspberry Pi Zero 2 W 的便携式 USB 协议 Fuzzing 与设备模拟工具(开源 · 网页操控)

USB Fuzzer — 基于 Raspberry Pi Zero 2 W 的便携式 USB 协议 Fuzzing 与设备模拟工具(开源 · 网页操控)

[AI 整理声明] 本文基于作者的项目文档与开发实践,由 AI 辅助整理输出,核心内容与数据均来自作者本人。 目录硬件部署设备模拟USB Fuzz日志系统信息架构注意USB 是整机设备的通用外设入口,主机侧的 USB 协议栈(枚举、描述符解析、…

2026/7/22 1:53:59阅读更多 →
C# 11新特性解析与应用实践

C# 11新特性解析与应用实践

1. C# 11新特性全景概览C# 11作为微软2022年推出的重要版本更新,带来了诸多令人振奋的语言增强。这些新特性并非简单的语法糖,而是从编译器层面进行的根本性改进,显著提升了开发效率、代码安全性和表达力。根据我在实际项目中的使用体验&…

2026/7/22 1:53:59阅读更多 →
深入解析C2000 Bootloader数据流与多模式引导实现

深入解析C2000 Bootloader数据流与多模式引导实现

1. 项目概述与核心价值在嵌入式系统开发中,我们常常会面对一个看似简单却至关重要的环节:系统如何从“一片空白”的状态,加载并运行我们精心编写的应用程序?这个问题的答案,就是引导加载程序,也就是我们常说…

2026/7/22 1:51:59阅读更多 →
Go语言静态资源打包方案对比与实践指南

Go语言静态资源打包方案对比与实践指南

1. 项目背景与核心需求在Go语言开发中,我们经常需要处理静态资源文件的打包问题。无论是Web应用的模板文件、前端资源,还是配置文件、证书等,都需要随程序一起分发。传统做法是将这些文件与编译后的二进制文件放在同一目录下,但这…

2026/7/22 0:53:59阅读更多 →
Go语言实现高性能LDAP认证服务的架构与实践

Go语言实现高性能LDAP认证服务的架构与实践

1. 项目背景与核心价值LDAP(轻量级目录访问协议)作为企业级身份认证的黄金标准,已经服务了超过80%的财富500强公司。我在金融科技领域实施统一认证体系时,发现传统Java方案存在启动慢、内存占用高等痛点。而Go语言凭借其协程并发模…

2026/7/22 0:53:59阅读更多 →
【AI面试官实战指南】:用ChatGPT模拟10类高频技术岗面试,3天提升应答精准度92%

【AI面试官实战指南】:用ChatGPT模拟10类高频技术岗面试,3天提升应答精准度92%

更多请点击: https://intelliparadigm.com 第一章:AI面试官实战指南的核心价值与适用场景 AI面试官并非替代人类HR的“黑箱工具”,而是以可解释、可审计、可迭代的方式,赋能招聘全链路的关键基础设施。其核心价值在于将主观经验沉…

2026/7/22 0:53:59阅读更多 →
中小企业小程序开发公司怎么选:预算、上手和售后避坑指南

中小企业小程序开发公司怎么选:预算、上手和售后避坑指南

中小企业做小程序,最常见的矛盾是预算有限,但又不希望功能太单薄;没有技术团队,但又希望后续能自己运营;想快速上线,又担心隐性收费和售后失联。选型时如果只看“低价套餐”或“案例数量”,很容…

2026/7/22 0:01:17阅读更多 →
GEO优化如何沉淀长期内容资产?广拓时代谈AI搜索时代的内容ROI

GEO优化如何沉淀长期内容资产?广拓时代谈AI搜索时代的内容ROI

企业做营销,最怕钱花完了,资产没有留下。 效果广告能带来一段时间的曝光,但预算停止后,流量往往也随之停止。短视频内容可能在几天内冲高,也可能很快沉下去。AI搜索时代,企业需要重新思考一个问题&#xff…

2026/7/22 0:01:17阅读更多 →
Agent 终态判定:何时该停止思考、给出最终回复

Agent 终态判定:何时该停止思考、给出最终回复

Agent 终态判定:何时该停止思考、给出最终回复 一、你的 Agent 在"再想想"的循环里绕了 12 轮,用户已经关窗口了 Agent 与人最大的区别是:人知道什么时候该停下来给答案,Agent 会一直"想"下去。你给 Agent 接…

2026/7/22 0:01:17阅读更多 →
YOLOv8推理性能优化:从1.2FPS到35FPS的全链路加速实践

YOLOv8推理性能优化:从1.2FPS到35FPS的全链路加速实践

如果你在部署 YOLOv8 时,发现推理速度只有可怜的 1-2 FPS,而别人的演示视频却能跑到 30 FPS 以上,那么问题很可能不在模型本身,而在于你的整个处理链路。很多开发者拿到一个训练好的 YOLOv8 模型后,会直接使用官方示例…

2026/7/21 22:53:50阅读更多 →
Coze与Dify对比指南:低代码AI应用开发从入门到实战

Coze与Dify对比指南:低代码AI应用开发从入门到实战

1. 从零到一:为什么你需要了解 Coze 和 Dify?如果你对 AI 应用开发感兴趣,但一看到“大模型”、“智能体”、“工作流”这些词就头疼,觉得门槛太高,那这篇文章就是为你准备的。很多开发者,包括我自己&#…

2026/7/21 18:53:30阅读更多 →
AI生图工具怎么选?2026年6月版实测对比

AI生图工具怎么选?2026年6月版实测对比

做自媒体的朋友应该都有体会:配图一直是个让人头疼的问题。2026年,AI生图工具已经非常成熟了,但工具太多反而不知道怎么选。以下是截至2026年6月我对主流AI生图工具的实测对比。Midjourney V8.1:速度之王2026年6月11日&#xff0c…

2026/7/21 18:53:30阅读更多 →