Official编程与开发github.com

xlsx

在电子表格文件是主要输入或输出时使用此技能,包括打开、读取、编辑或创建 .xlsx、.xlsm、.xltx、.csv、.tsv 文件,以及在表格文件格式之间转换。

xlsx 是什么?

该技能专注于处理电子表格文件(如 .xlsx、.xlsm、.csv、.tsv),支持创建、编辑、分析和转换。它封装了 openpyxl 和 pandas 等工具,并提供了详细的指导原则,以生成专业、无错误的电子表格。技能要求使用公式而非硬编码结果,强制通过 LibreOffice 重新计算以验证公式,并详细说明了 openpyxl 的常见陷阱(如双向读取模型、合并单元格处理)。它还包含了财务模型的格式化约定(如颜色编码、数字格式)和跨平台兼容性建议(如避免使用无法在 LibreOffice 中计算的函数)。此技能适用于任何需要处理电子表格的任务,确保输出符合商业或分析标准。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/anthropics/skills/tree/main/skills/xlsx

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

XLSX 创建、编辑和分析

任务方法
创建或编辑(含公式/格式)openpyxl — 参见下面的注意事项
批量数据导入或导出pandas(read_excel、to_excel)
快速查看工作表markitdown file.xlsx — 每个工作表以 ## SheetName 形式显示;也支持 .xlsm。不含单元格坐标,因此不要据此计划编辑
读取模型(公式和值)两次 load_workbook 调用 — 参见注意事项

openpyxl、pandas 和 markitdown 已预装 — 请勿先运行 pip install;直接编写脚本并导入。仅当导入失败(或 markitdown 命令缺失)时,运行 pip install 安装缺失的包。

以下脚本路径相对于本技能目录。

每个输出的要求

  • 专业字体(Arial、Times New Roman)贯穿全文,除非用户另有要求。
  • 零公式错误。 绝不要输出 recalc.py 报告 errors_found 的文件。如果你认为错误在你之前就已存在,请证明:用 data_only=True 加载原文件并查看该单元格。你引入的错误看起来与继承的错误完全相同。
  • 使用公式,绝不使用硬编码结果。 写入 sheet['B10'] = '=SUM(B2:B9)',而不是 Python 计算的总和。工作表必须在输入变化时重新计算。
  • 严格遵循用户的规格说明。 确切的选项卡名称、确切的列标题以及他们明确说明的公式。任何计算其他内容的重新设计都是失败的,无论多么优雅。
  • 记录每个假设和硬编码数字,放在读者能看到的地方 — 单元格批注,或表格末尾的相邻单元格。有真实来源时引用来源(来源:公司 10-K,2024 财年,第 45 页,收入附注,[SEC EDGAR URL]);当数字来自用户时,直接说明。
  • 你创建的、供他人填写的工作簿需要包含一个简短的图例,说明哪些单元格需要编辑,并包含一行示例行,显示预期的格式并包含真实值。绝不要将这样的示例行添加到被要求编辑的文件中。
  • 编辑现有文件时:完全遵循其约定。 它们覆盖这里的每一条指南。首先找到其指定的输入单元格 — 通常以不同的字体颜色、填充或阴影标记 — 仅在这些单元格中写入,并保持所有现有公式不变。

重新计算(只要文件包含公式就必须执行)

openpyxl 将公式写为字符串,不包含缓存值。在重新计算之前,每个公式单元格对读取缓存值的任何内容 — pandas、load_workbook(data_only=True) 和大多数预览器 — 都返回 None。

python scripts/recalc.py output.xlsx [timeout_seconds]   # 默认 30

LibreOffice 计算每个公式,文件被就地重写,并返回 JSON:status(success | errors_found)、total_formulas、total_errors 以及一个 error_summary,每种错误类型最多命名 100 个单元格(locations_truncated 表示它省略了多少个 — 相信 total_errors,而不是列表的长度)。修复它命名的内容并再次运行。JSON 包含 error 键而非 status 键表示没有进行任何重新计算,只有这种情况会退出并返回非零状态 — errors_found 退出状态为 0,所以绝不要将干净的退出视为工作簿干净。

一次成功的重新计算证明你的公式可求值,而不是它们是正确的。 一个差一错误的范围或引用错误行的公式会生成一个干净、无错误但数字错误的数据。在构建整个网格之前,先编写 2-3 个公式并检查它们是否按预期拉取数值。

一个链接到其他文件的工作簿如果使用 openpyxl 重新保存然后重新计算,就会丢失这些链接。这样的公式读起来像 ='[1]Returns Analysis'!$B$2 — 其中 [1] 是工作簿外部引用列表中的索引,命名的是磁盘上的一个单独文件,而不是一个工作表。该文件在这里很少存在,因此该单元格的缓存值是唯一保存其数据的东西。openpyxl 在保存时会剥离该值;然后 LibreOffice 必须真正解析该引用,失败,写入 #NAME?,并删除所有链接。recalc.py 在这种状态下拒绝运行 — 在覆盖保存之前,将那些单元格的值从原始文件中复制出来(--force 会覆盖并接受数据丢失)。

选择能通过验证的公式

LibreOffice 实现的函数比 Excel 少,它无法求值的函数会成为你交付文件中固定的 #NAME?。

  • 优先使用 Excel 2007 时代及更早的函数 — SUMIFS、INDEX、MATCH、IFERROR、SUMPRODUCT — 这些函数不需要前缀。
  • 六个 2007 年之后的函数可以工作,但需要 _xlfn. 前缀,因为 openpyxl 将你的公式原样写入 XML,而 Excel 存储 2007 年之后的名称时带有前缀(其 UI 隐藏了该前缀):_xlfn.TEXTJOIN、_xlfn.CONCAT、_xlfn.IFS、_xlfn.SWITCH、_xlfn.MAXIFS、_xlfn.MINIFS。如果直接编写,每个都会产生 #NAME?。
  • 绝不要使用 XLOOKUP、XMATCH、SORT、FILTER、UNIQUE 或 SEQUENCE。 运行时的 LibreOffice 无法在任何前缀下评估它们。较新的版本可以评估它们,但它们会溢出数组函数,而用 openpyxl 写入的文件没有溢出元数据,因此只有该范围的左上角单元格会获得一个值 — 而 recalc.py 会在截断的结果上报告 total_errors: 0。对于查找,使用 INDEX/MATCH;在写入单元格之前,在 Python 中完成排序、筛选和去重。
  • 一个 LibreOffice 无法解析的公式会被小写写回 — 这是在 #NAME? 旁边的快速判断标志。

openpyxl 注意事项

  • 读取模型需要两次加载。 data_only=True 返回缓存值,但公式消失;默认值返回公式字符串,但没有值。一次调用无法同时提供两者。
  • 如果保存,data_only=True 具有破坏性。 该工作簿不再包含任何公式,因此保存会将每个公式永久替换为字面量。
  • 对刚刚由 openpyxl 写入的文件使用 data_only=True 会全部返回 None — 先运行 recalc.py。(结果为 "" 的公式也会读回为 None。)
  • 合并单元格:只写入左上角的锚点。 区域中的每个其他单元格都是只读的 MergedCell。
  • 除非向 load_workbook 传递 keep_vba=True,否则 .xlsm 会丢失其宏。
  • 包含空格的工作表名称在跨工作表引用中必须加引号:='Assumptions Inputs'!$B$5。不加引号会求值为 #VALUE!。

财务模型

除非用户另有说明,或现有文件已经采用了其他方式。

颜色: 蓝色文本(0,0,255)用于硬编码输入和情景杠杆 · 黑色用于公式 · 绿色(0,128,0)用于指向其他工作表的链接 · 红色(255,0,0)用于指向其他文件的链接 · 黄色填充(255,255,0)用于关键假设和用户应填写的单元格。

数字: 货币 $#,##0,在标题中注明单位(Revenue ($mm)) · 零显示为 -,包括百分比($#,##0;($#,##0);-) · 负数显示在括号中 · 百分比 0.0%,存储为小数(0.15 显示为 15.0%;存储 15 会显示 1500.0%) · 估值倍数 0.0x · 年份显示为文本("2024",绝不要 2,024)。

结构: 每个假设都在其自己的标记单元格中,由使用它的公式引用(=B5*(1+$B$6),绝不要 =B5*1.05) · 每个预测期间的公式保持一致,因为行中间单独编辑的单元格是最常见的无声错误 · 保护可能为零的分母。

依赖项

openpyxl、pandas、markitdown(pip,已预装 — 仅当导入失败或命令缺失时安装) · LibreOffice(soffice,通过 scripts/office/soffice.py 自动配置适用于沙箱环境)

Individual skills in this repo

This repo contains 19 individual skills — each has its own dedicated page.

academy-guide

Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content.

algorithmic-art

Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists

anthropics/template-skill

Replace with description of the skill and when Claude should use it.

brand-guidelines

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

canvas-design

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists

claude-api

|-

discernment-nudge

After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format.

doc-coauthoring

Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.

docx

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of

frontend-design

Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.

internal-comms

A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).

mcp-builder

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

pdf

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

pptx

Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions \

skill-creator

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill

slack-gif-creator

Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like

theme-factory

Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

webapp-testing

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

web-artifacts-builder

Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.

相关技能