Communitygithub.com

xlsx

创建、编辑、分析或转换Excel电子表格(.xlsx、.xlsm、.xltx),以工作簿文件为主要交付物。适用于公式、格式、财务模型、多工作表工作簿以及导出为Excel的表格清理。也适用于用户需要电子表格输出的.csv/.tsv文件。不要用于Word文档、HTML报告、独立Python脚本、数据库管道或Google Sheets API工作。

xlsx 是什么?

该技能专为需要以Excel工作簿作为最终交付物的任务而设计,支持使用openpyxl、pandas和markitdown库进行创建、编辑、分析和转换操作。它提供了详细的指导,包括公式编写规范、格式要求(如专业字体、颜色规则)、财务模型结构约定,以及强制性的重新计算步骤(通过recalc.py脚本,基于LibreOffice引擎)。该技能特别强调了零错误交付(公式无#NAME?等错误)、使用公式而非硬编码值、严格遵循用户规格,以及处理外部链接、合并单元格、宏等特殊情况的注意事项。支持的文件格式包括.xlsx、.xlsm、.xltx以及.csv/.tsv(当用户需要电子表格输出时)。不适用于Word文档、HTML报告或Google Sheets API工作。

兼容平台✓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,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,而不是列表的长度)。修复它命名的内容并再次运行。包含error键而非status的JSON表示未进行任何重新计算,仅此情况会以非零退出 — 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,并在标题中注明单位(收入($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.

相关技能