办公文档处理_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:00 阅读更多 →
SpringBoot+Vue超市管理系统:一小时极速搭建与核心流程解析

SpringBoot+Vue超市管理系统:一小时极速搭建与核心流程解析

最近在帮几个学弟学妹看期末大作业,发现一个挺有意思的现象:很多人一听到“超市管理系统”或者“SpringBootVue前后端分离”,第一反应就是去网上找源码,然后试图在一天内“跑起来”交差。结果往往是,环境报错、数据库连…

2026/7/21 23:20:00 阅读更多 →
企业家AI原生学习平台推荐:AI迭代一日千里,高参学堂直击行业前沿

企业家AI原生学习平台推荐:AI迭代一日千里,高参学堂直击行业前沿

现下,AI技术迭代速度远超以往任何产业。麦肯锡《2025年AI现状报告》显示,88%的企业已在至少一个业务中部署AI,但近三分之二仍停留在试验阶段,未能规模化落地。与此同时,斯坦福《2026 AI指数报告》指出,全球企业AI投资飙升至5817亿美元,中美AI差距已缩小至2.7%——技术红利窗口正…

2026/7/21 23:20:00 阅读更多 →

最新新闻

iOS开发必备第三方框架选型与优化指南

iOS开发必备第三方框架选型与优化指南

1. iOS开发必备第三方框架全景图在iOS开发生态中,第三方框架如同瑞士军刀般不可或缺。根据GitHub上超过4000星标的Srefan-iOS项目统计,主流App平均集成15-20个第三方库。这些框架主要解决三类核心问题:基础功能增强(如网络请求&am…

2026/7/22 1:13:15 阅读更多 →
COM组件开发核心技术解析与实践指南

COM组件开发核心技术解析与实践指南

1. COM组件基础概念回顾 COM(Component Object Model)是微软在1993年提出的二进制接口标准,它定义了一套组件间交互的规范。作为Windows平台的核心技术之一,COM解决了软件组件复用和跨语言调用的问题。我在实际开发中发现&#xf…

2026/7/22 1:13:15 阅读更多 →
3个痛点场景下,Escrcpy如何重新定义Android设备管理体验?

3个痛点场景下,Escrcpy如何重新定义Android设备管理体验?

3个痛点场景下,Escrcpy如何重新定义Android设备管理体验? 【免费下载链接】escrcpy 📱 Display and control your Android device graphically with scrcpy. 项目地址: https://gitcode.com/GitHub_Trending/es/escrcpy 你是否曾因需要…

2026/7/22 1:13:15 阅读更多 →
语义缓存实战:AI API 调用成本如何降低 70%?

语义缓存实战:AI API 调用成本如何降低 70%?

📊 从月均 5000 元到 1000 元,语义缓存如何实现成本断崖式下降?本文带你深入技术原理与落地实践。 一、为什么你的 AI 应用在“烧钱”? 智能客服每天处理大量用户提问,但真正全新的问题只占 20%: 20% 完全重…

2026/7/22 1:13:15 阅读更多 →
ownCloud Infinite Scale完全指南:10分钟掌握下一代文件同步平台

ownCloud Infinite Scale完全指南:10分钟掌握下一代文件同步平台

ownCloud Infinite Scale完全指南:10分钟掌握下一代文件同步平台 【免费下载链接】ocis :atom_symbol: ownCloud Infinite Scale 项目地址: https://gitcode.com/GitHub_Trending/oc/ocis 在当今数字化时代,文件同步与共享已成为企业和个人工作流…

2026/7/22 1:13:15 阅读更多 →
国产AI编程工具OpenCode与国产大模型实践指南

国产AI编程工具OpenCode与国产大模型实践指南

1. 国内开发者面临的AI编程工具困境作为长期在一线编码的开发者,我深刻感受到当前AI编程工具在国内使用中的痛点。主流工具如GitHub Copilot、Claude Code等虽然强大,但面临着三大现实问题:首先是网络稳定性问题。由于众所周知的原因&#xf…

2026/7/22 1:12:14 阅读更多 →

日新闻

TI DSP系统配置模块SYSCFG详解:中断机制与主设备优先级配置实战

TI DSP系统配置模块SYSCFG详解:中断机制与主设备优先级配置实战

1. 项目概述与SYSCFG模块的核心价值在嵌入式系统,尤其是像TI C6000系列这样的高性能DSP开发中,我们常常会与芯片手册里那些密密麻麻的寄存器打交道。很多开发者可能更关注算法实现、内存优化或者外设驱动,但对于一个稳定、高效的系统而言&…

2026/7/22 0:00:26 阅读更多 →
微信Server酱:高到达率的应急通知方案实践

微信Server酱:高到达率的应急通知方案实践

1. 为什么我们需要"最次"的通知方案? 在数字化协作环境中,消息通知系统的重要性不言而喻明。但现实情况是,企业级通知方案往往需要复杂的API对接(如企业微信、钉钉、飞书),个人开发者的小项目又经…

2026/7/22 0:00:26 阅读更多 →
甲方要的“简洁“PPT,到底是简洁还是省事?

甲方要的“简洁“PPT,到底是简洁还是省事?

甲方说"简洁一点",乙方听到的是"少做几页"。甲方说"不要太复杂",乙方理解成"别放图表了"。结果交过去,甲方说"我说的简洁不是这个意思"。"简洁"这个词在PPT语境里,是…

2026/7/22 0:00:26 阅读更多 →

周新闻

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

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

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

2026/7/21 8:48:31 阅读更多 →
Go语言实现高性能LDAP认证服务的架构与实践

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

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

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

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

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

2026/7/21 8:25:39 阅读更多 →

月新闻