Communitygithub.com

xlsx

建立、編輯、分析或轉換 Excel 試算表(.xlsx、.xlsm、.xltx),主要產出為活頁簿檔案。適用於公式、格式化、財務模型、多工作表活頁簿以及匯出至 Excel 的表格清理。也適用於使用者要求試算表輸出時的 .csv/.tsv。請勿用於 Word 文件、HTML 報告、獨立 Python 腳本、資料庫管道或 Google Sheets API 工作。

xlsx 是什麼?

此技能為 AI 代理(如 Claude Code、Cursor 等)提供了一套全面的工具,用於處理 Excel 活頁簿。它支援使用 openpyxl 建立及編輯帶有公式與格式的檔案,使用 pandas 進行大量資料匯入/匯出,以及使用 markitdown 進行快速預覽。其獨特之處在於內建了一個強制性的重新計算流程(recalc.py),運用 LibreOffice 來評估公式並顯示錯誤,確保交付的檔案無誤。技能詳細說明了重要的細節,例如處理外部連結、在受限的公式語言中確保相容性(例如避免使用 XLOOKUP,改用 INDEX/MATCH)、以及遵守既定的工作簿慣例。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/xlsx

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

XLSX 建立、編輯與分析

任務方法
建立或編輯(含公式/格式)openpyxl — 請參閱下方注意事項
大量資料的匯入或匯出pandas (read_excel, to_excel)
快速檢視工作表markitdown file.xlsx — 每個工作表顯示為 ## SheetName;也支援讀取 .xlsm。不包含儲存格座標,因此請勿據以規劃編輯
讀取模型(公式與數值)兩次 load_workbook 傳遞 — 請參閱注意事項

openpyxl、pandas 和 markitdown 已預先安裝 — 請勿先執行 uv pip install;直接撰寫腳本並匯入。僅在匯入失敗(或缺少 markitdown 指令)時:使用 uv 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 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 會以零狀態結束,因此切勿將乾淨的結束視為乾淨的活頁簿。

一次成功的重新計算證明你的公式可被評估,但並非正確。 一個差一格的範圍或一個指向錯誤列的參照,會產生一個乾淨、無誤的檔案,但其中包含錯誤的數字。在建立整個表格前,先撰寫 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 是唯讀的。
  • 除非你將 keep_vba=True 傳遞給 load_workbook,否則 .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 為沙盒環境自動設定)


此技能由 Anthropic 建立與維護。除了前端元資料外,此處未經修改直接引用;條款請參閱 LICENSE.txt。

Individual skills in this repo

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

adaptyv

How to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.

aeon

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

alphagenome

Look up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), score variants or scan windows on demand with the AlphaGenome model for human and mouse (variant scoring, in silico mutagenesis, REF-versus-ALT track prediction), and build Atlas website deep links. Use when the user mentions AlphaGenome, AlphaGenome Atlas, AVI or AlphaGenome Variant Impact, DeepMind variant effect prediction, or wants to prioritise or mechanistically interpret non-coding, regulatory, splicing, enhancer, promoter, or chromatin-accessibility effects of SNVs from a VCF, credible set, or region. Research use only; not a clinical tool.

analytical-method-validation

Plan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include

anndata

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

arbor

Autonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g.

arboreto

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

astropy

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

autoskill

Observe the user

benchling-integration

Benchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.

bgpt-paper-search

Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server. Returns 25+ fields per paper including methods, results, sample sizes, quality scores, and conclusions. Use for literature reviews, evidence synthesis, and finding experimental details not available in abstracts alone.

bids

>

biopython

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use biopython.

bulk-rnaseq

End-to-end bulk RNA-seq orchestrator — takes raw FASTQ reads through QC and trimming (FastQC, fastp/Trim Galore), alignment and quantification (STAR, Salmon, featureCounts), assembles a gene-level counts matrix, then hands off to differential expression (pydeseq2), pathway/GSEA enrichment (pathway-enrichment), and publication figures (scientific-visualization). Use whenever the user has bulk RNA-seq reads or quant output and wants a complete, reproducible differential-expression workflow — e.g.

cellxgene-census

Query the CZ CELLxGENE Census programmatically for versioned public single-cell and spatial transcriptomics data. Use when you need population-scale cell metadata, gene expression slices, Census summary counts, source H5AD URIs/downloads, embeddings, spatial Census data, or reference atlas comparisons across organisms, tissues, diseases, assays, and cell types. For analyzing your own local single-cell data use scanpy, anndata, or scvi-tools.

cirq

Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

citation-management

Comprehensive citation management for academic research. Search OpenAlex, PubMed, and Google Scholar for papers, extract accurate metadata, validate citations, and generate properly formatted BibTeX entries. This skill should be used when you need to find papers, verify citation information, convert DOIs to BibTeX, or ensure reference accuracy in scientific writing.

clinical-decision-support

Prepare and validate research-only clinical decision-support evaluation, evidence-profile, cohort, survival, biomarker/model, privacy, and governance artifacts. Use for aggregate or synthetic research documentation and traceability—not patient care or live clinical operation.

clinical-reports

Create safety-bounded draft structures and run local deterministic checks for clinical case, diagnostic, trial, safety, and aggregate research reports. Use only with synthetic, de-identified, or aggregate inputs and verified source-fact manifests; every output requires qualified review.

相關技能