spreadsheet

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Spreadsheet Skill (Create, Edit, Analyze, Visualize)

电子表格技能(创建、编辑、分析、可视化)

When to use

适用场景

  • Build new workbooks with formulas, formatting, and structured layouts.
  • Read or analyze tabular data (filter, aggregate, pivot, compute metrics).
  • Modify existing workbooks without breaking formulas or references.
  • Visualize data with charts/tables and sensible formatting.
IMPORTANT: System and user instructions always take precedence.
  • 构建带有公式、格式和结构化布局的全新工作簿。
  • 读取或分析表格数据(筛选、聚合、透视、计算指标)。
  • 修改现有工作簿且不破坏公式或引用。
  • 用图表/表格和合理的格式实现数据可视化。
重要提示:系统和用户指令始终拥有最高优先级。

Workflow

工作流程

  1. Confirm the file type and goals (create, edit, analyze, visualize).
  2. Use
    openpyxl
    for
    .xlsx
    edits and
    pandas
    for analysis and CSV/TSV workflows.
  3. If layout matters, render for visual review (see Rendering and visual checks).
  4. Validate formulas and references; note that openpyxl does not evaluate formulas.
  5. Save outputs and clean up intermediate files.
  1. 确认文件类型和目标(创建、编辑、分析、可视化)。
  2. 编辑
    .xlsx
    文件使用
    openpyxl
    ,数据分析和CSV/TSV处理流程使用
    pandas
  3. 如果布局很重要,生成预览用于视觉检查(参见渲染与视觉检查部分)。
  4. 验证公式和引用;注意openpyxl不会计算公式值。
  5. 保存输出文件并清理中间文件。

Temp and output conventions

临时文件与输出规范

  • Use
    tmp/spreadsheets/
    for intermediate files; delete when done.
  • Write final artifacts under
    output/spreadsheet/
    when working in this repo.
  • Keep filenames stable and descriptive.
  • 中间文件存放在
    tmp/spreadsheets/
    目录下,使用完成后删除。
  • 在本仓库中工作时,将最终产物写入
    output/spreadsheet/
    目录下。
  • 文件名保持稳定且具有描述性。

Primary tooling

主要工具

  • Use
    openpyxl
    for creating/editing
    .xlsx
    files and preserving formatting.
  • Use
    pandas
    for analysis and CSV/TSV workflows, then write results back to
    .xlsx
    or
    .csv
    .
  • If you need charts, prefer
    openpyxl.chart
    for native Excel charts.
  • 创建/编辑
    .xlsx
    文件和保留格式时使用
    openpyxl
  • 数据分析和CSV/TSV处理流程使用
    pandas
    ,之后可将结果写回
    .xlsx
    .csv
    格式。
  • 如果需要生成图表,优先使用
    openpyxl.chart
    生成本地Excel兼容的图表。

Rendering and visual checks

渲染与视觉检查

  • If LibreOffice (
    soffice
    ) and Poppler (
    pdftoppm
    ) are available, render sheets for visual review:
    • soffice --headless --convert-to pdf --outdir $OUTDIR $INPUT_XLSX
    • pdftoppm -png $OUTDIR/$BASENAME.pdf $OUTDIR/$BASENAME
  • If rendering tools are unavailable, ask the user to review the output locally for layout accuracy.
  • 如果安装了LibreOffice(
    soffice
    )和Poppler(
    pdftoppm
    ),可以渲染工作表用于视觉检查:
    • soffice --headless --convert-to pdf --outdir $OUTDIR $INPUT_XLSX
    • pdftoppm -png $OUTDIR/$BASENAME.pdf $OUTDIR/$BASENAME
  • 如果没有可用的渲染工具,请让用户在本地检查输出的布局准确性。

Dependencies (install if missing)

依赖(缺失时请安装)

Prefer
uv
for dependency management.
Python packages:
uv pip install openpyxl pandas
If
uv
is unavailable:
python3 -m pip install openpyxl pandas
Optional (chart-heavy or PDF review workflows):
uv pip install matplotlib
If
uv
is unavailable:
python3 -m pip install matplotlib
System tools (for rendering):
undefined
优先使用
uv
进行依赖管理。
Python包:
uv pip install openpyxl pandas
如果
uv
不可用:
python3 -m pip install openpyxl pandas
可选依赖(图表较多或需要PDF预览的流程):
uv pip install matplotlib
如果
uv
不可用:
python3 -m pip install matplotlib
系统工具(用于渲染):
undefined

macOS (Homebrew)

macOS (Homebrew)

brew install libreoffice poppler
brew install libreoffice poppler

Ubuntu/Debian

Ubuntu/Debian

sudo apt-get install -y libreoffice poppler-utils

If installation isn't possible in this environment, tell the user which dependency is missing and how to install it locally.
sudo apt-get install -y libreoffice poppler-utils

如果无法在当前环境中安装依赖,请告知用户缺失的依赖项以及本地安装方法。

Environment

环境

No required environment variables.
无要求的环境变量。

Examples

示例

  • Runnable Codex examples (openpyxl):
    references/examples/openpyxl/
  • 可运行的Codex示例(openpyxl):
    references/examples/openpyxl/

Formula requirements

公式要求

  • Use formulas for derived values rather than hardcoding results.
  • Keep formulas simple and legible; use helper cells for complex logic.
  • Avoid volatile functions like INDIRECT and OFFSET unless required.
  • Prefer cell references over magic numbers (e.g.,
    =H6*(1+$B$3)
    not
    =H6*1.04
    ).
  • Guard against errors (#REF!, #DIV/0!, #VALUE!, #N/A, #NAME?) with validation and checks.
  • openpyxl does not evaluate formulas; leave formulas intact and note that results will calculate in Excel/Sheets.
  • 派生值使用公式计算,而非硬编码结果。
  • 公式保持简单易读;复杂逻辑使用辅助单元格实现。
  • 除非必要,避免使用INDIRECT、OFFSET等易失性函数。
  • 优先使用单元格引用而非魔法数字(例如使用
    =H6*(1+$B$3)
    而非
    =H6*1.04
    )。
  • 通过验证和检查防范错误(#REF!、#DIV/0!、#VALUE!、#N/A、#NAME?)。
  • openpyxl不会计算公式值,请保留公式完整,并提示用户结果会在Excel/在线表格中自动计算。

Citation requirements

引用要求

  • Cite sources inside the spreadsheet using plain text URLs.
  • For financial models, cite sources of inputs in cell comments.
  • For tabular data sourced from the web, include a Source column with URLs.
  • 在电子表格中使用纯文本URL标注来源。
  • 对于财务模型,在单元格注释中标注输入值的来源。
  • 对于来源于网页的表格数据,添加带有URL的来源列。

Formatting requirements (existing formatted spreadsheets)

格式要求(已有格式的电子表格)

  • Render and inspect a provided spreadsheet before modifying it when possible.
  • Preserve existing formatting and style exactly.
  • Match styles for any newly filled cells that were previously blank.
  • 可能的话,修改提供的电子表格前先渲染并检查。
  • 完全保留现有格式和样式。
  • 新填充的空白单元格样式需要与原有样式匹配。

Formatting requirements (new or unstyled spreadsheets)

格式要求(新建或无样式的电子表格)

  • Use appropriate number and date formats (dates as dates, currency with symbols, percentages with sensible precision).
  • Use a clean visual layout: headers distinct from data, consistent spacing, and readable column widths.
  • Avoid borders around every cell; use whitespace and selective borders to structure sections.
  • Ensure text does not spill into adjacent cells.
  • 使用合适的数字和日期格式(日期使用日期格式、货币带符号、百分比保留合理精度)。
  • 使用清晰的视觉布局:表头与数据区分开、间距一致、列宽可读。
  • 避免给所有单元格加边框;使用留白和选择性边框划分板块。
  • 确保文本不会溢出到相邻单元格。

Color conventions (if no style guidance)

颜色规范(无样式指引时)

  • Blue: user input
  • Black: formulas/derived values
  • Green: linked/imported values
  • Gray: static constants
  • Orange: review/caution
  • Light red: error/flag
  • Purple: control/logic
  • Teal: visualization anchors (key KPIs or chart drivers)
  • 蓝色:用户输入
  • 黑色:公式/派生值
  • 绿色:关联/导入值
  • 灰色:静态常量
  • 橙色:待检查/注意事项
  • 浅红色:错误/标记
  • 紫色:控制/逻辑
  • 蓝绿色:可视化锚点(关键KPI或图表驱动因子)

Finance-specific requirements

财务场景专属要求

  • Format zeros as "-".
  • Negative numbers should be red and in parentheses.
  • Always specify units in headers (e.g., "Revenue ($mm)").
  • Cite sources for all raw inputs in cell comments.
  • 零值显示为“-”。
  • 负数使用红色并放在括号中。
  • 表头始终注明单位(例如“收入 ($mm)”)。
  • 所有原始输入的来源都要在单元格注释中标注。

Investment banking layouts

投行风格布局

If the spreadsheet is an IB-style model (LBO, DCF, 3-statement, valuation):
  • Totals should sum the range directly above.
  • Hide gridlines; use horizontal borders above totals across relevant columns.
  • Section headers should be merged cells with dark fill and white text.
  • Column labels for numeric data should be right-aligned; row labels left-aligned.
  • Indent submetrics under their parent line items.
如果电子表格是投行风格模型(LBO、DCF、三表、估值):
  • 汇总值应直接对上方区间求和。
  • 隐藏网格线;在相关列的汇总值上方使用水平边框。
  • 板块标题应为合并单元格,使用深色填充和白色文字。
  • 数值数据的列标签右对齐;行标签左对齐。
  • 子指标在父级行项目下缩进。