Official程式設計與開發github.com

xlsx

在試算表檔案(如 .xlsx、.xlsm、.csv、.tsv 等)作為主要輸入或輸出時使用,支援建立、讀取、編輯、分析及格式轉換。

xlsx 是什麼?

此技能專為需要處理試算表檔案的場景設計,涵蓋開啟、讀取、編輯、修復 .xlsx、.xlsm、.xltx、.csv 或 .tsv 檔案,以及建立新試算表或在不同表格格式之間轉換的任務。只要使用者提及試算表檔案名稱或路徑,即使語氣輕鬆,也應觸發此技能。 技能基於 `openpyxl`、`pandas` 和 `markitdown` 等內建套件,支援公式計算、格式設定、圖表繪製以及資料清理。特別強調使用公式而非硬編碼結果,並透過 `recalc.py` 腳本驗證所有公式的正確性(利用 LibreOffice 進行實際運算)。對於包含外部連結或巨集的 .xlsm 檔案,也提供了相應的處理指引,例如使用 `keep_vba=True` 保留巨集。 此外,技能定義了明確的輸出規範,包括字型要求(Arial 或 Times New Roman)、零公式錯誤原則,以及對財務模型的特殊格式與顏色編碼。所有假設與硬編碼數字都需附加註解或來源引用。對於使用者要求編輯的既有檔案,則需嚴格遵循其原有慣例。

相容平台~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,FY2024,第 45 頁,收入附註,[SEC EDGAR 網址]);若數字來自使用者,請直接說明。
  • 你為讓他人填寫而建立的活頁簿需要一個簡短圖例,標明哪些儲存格需要編輯,以及一個範例列,使用真實值展示預期格式。對於被要求編輯的檔案,切勿加入此類範例列。
  • 編輯現有檔案:嚴格比對其慣例。 它們會覆蓋此處的所有指南。首先找出其指定的輸入儲存格(通常有獨特的字型顏色、填滿或陰影標記),僅在該處寫入,並保持所有既有公式不變。

重新計算(每當檔案包含公式時強制執行)

openpyxl 將公式寫為字串,且不包含快取值。在重新計算之前,每個公式儲存格對於任何讀取快取值的東西(pandas、load_workbook(data_only=True) 及大多數預覽工具)都會傳回 None。

python scripts/recalc.py output.xlsx [超時秒數]   # 預設 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,其 .value 是唯讀的。
  • 除非在 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.

相關技能