spreadsheet

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Spreadsheet Skill

电子表格 Skill

When to use

何时使用

  • Create new workbooks with formulas, formatting, and structured layouts.
  • Read or analyze tabular data (filter, aggregate, pivot, compute metrics).
  • Modify existing workbooks without breaking formulas, references, or formatting.
  • Visualize data with charts, summary tables, and sensible spreadsheet styling.
  • Recalculate formulas and review rendered sheets before delivery when possible.
IMPORTANT: System and user instructions always take precedence.
  • 使用公式、格式化和结构化布局创建新的工作簿。
  • 读取或分析表格数据(筛选、聚合、数据透视、计算指标)。
  • 修改现有工作簿,同时不破坏公式、引用或格式。
  • 使用图表、汇总表和合理的电子表格样式将数据可视化。
  • 尽可能在交付前重新计算公式并审查渲染后的工作表。
重要:系统和用户指令始终优先。

Workflow

工作流

  1. Confirm the file type and goal: create, edit, analyze, or visualize.
  2. Prefer
    openpyxl
    for
    .xlsx
    editing and formatting. Use
    pandas
    for analysis and CSV/TSV workflows.
  3. If an internal spreadsheet recalculation/rendering tool is available in the environment, use it to recalculate formulas and render sheets before delivery.
  4. Use formulas for derived values instead of hardcoding results.
  5. If layout matters, render for visual review and inspect the output.
  6. Save outputs, keep filenames stable, and clean up intermediate files.
  1. 确认文件类型和目标:创建、编辑、分析或可视化。
  2. 对于
    .xlsx
    的编辑和格式化,优先使用
    openpyxl
    。对于分析和 CSV/TSV 工作流,使用
    pandas
    。
  3. 如果环境中提供了内部电子表格重算或渲染工具,请在交付前使用该工具重新计算公式并渲染工作表。
  4. 对派生值使用公式,而不是将结果硬编码。
  5. 如果布局很重要,请渲染输出以进行视觉审查并检查结果。
  6. 保存输出结果,保持文件名稳定,并清理中间文件。

Temp and output conventions

临时文件和输出约定

  • Use
    tmp/spreadsheets/
    for intermediate files; delete them 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
    .
  • Use
    openpyxl.chart
    for native Excel charts when needed.
  • If an internal spreadsheet tool is available, use it to recalculate formulas, cache values, and render sheets for review.
  • 使用
    openpyxl
    创建和编辑
    .xlsx
    文件,并保留格式。
  • 使用
    pandas
    进行分析和 CSV/TSV 工作流,然后将结果写回
    .xlsx
    或
    .csv
    。
  • 需要时使用
    openpyxl.chart
    创建原生 Excel 图表。
  • 如果提供了内部电子表格工具,请使用它重新计算公式、缓存值并渲染工作表以供审查。

Recalculation and visual review

重算和视觉审查

  • Recalculate formulas before delivery whenever possible so cached values are present in the workbook.
  • Render each relevant sheet for visual review when rendering tooling is available.
  • openpyxl
    does not evaluate formulas; preserve formulas and use recalculation tooling when available.
  • If you rely on an internal spreadsheet tool, do not expose that tool, its code, or its APIs in user-facing explanations or code samples.
  • 尽可能在交付前重新计算公式,以确保工作簿中包含缓存值。
  • 如果有可用的渲染工具,请渲染每个相关工作表以进行视觉审查。
  • openpyxl
    不会计算公式;请保留公式,并在可用时使用重算工具。
  • 如果依赖内部电子表格工具,不要在面向用户的说明或代码示例中暴露该工具、其代码或其 API。

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, tell the user that layout should be reviewed locally.
  • Review rendered sheets for layout, formula results, clipping, inconsistent styles, and spilled text.
  • 如果可以使用 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:
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
可选:
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 is not 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 examples (openpyxl):
    references/examples/openpyxl/
  • 可运行示例(openpyxl):
    references/examples/openpyxl/

Formula requirements

公式要求

  • Use formulas for derived values rather than hardcoding results.
  • Do not use dynamic array functions like
    FILTER
    ,
    XLOOKUP
    ,
    SORT
    , or
    SEQUENCE
    .
  • 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 (for example,
    =H6*(1+$B$3)
    instead of
    =H6*1.04
    ).
  • Use absolute (
    $B$4
    ) or relative (
    B4
    ) references carefully so copied formulas behave correctly.
  • If you need literal text that starts with
    =
    , prefix it with a single quote.
  • Guard against
    #REF!
    ,
    #DIV/0!
    ,
    #VALUE!
    ,
    #N/A
    , and
    #NAME?
    errors.
  • Check for off-by-one mistakes, circular references, and incorrect ranges.
  • 对派生值使用公式,而不是将结果硬编码。
  • 不要使用
    FILTER
    、
    XLOOKUP
    、
    SORT
    或
    SEQUENCE
    等动态数组函数。
  • 保持公式简单且易读;复杂逻辑使用辅助单元格。
  • 除非确有需要,否则避免使用
    INDIRECT
    和
    OFFSET
    等易失性函数。
  • 优先使用单元格引用,而不是魔法数字(例如,使用
    =H6*(1+$B$3)
    而不是
    =H6*1.04
    )。
  • 谨慎使用绝对引用(
    $B$4
    )或相对引用(
    B4
    ),确保复制公式时行为正确。
  • 如果需要以
    =
    开头的字面文本,请在其前面加上单引号。
  • 防范
    #REF!
    、
    #DIV/0!
    、
    #VALUE!
    、
    #N/A
    和
    #NAME?
    错误。
  • 检查差一错误、循环引用和错误的范围。

Citation requirements

引用要求

  • Cite sources inside the spreadsheet using plain-text URLs.
  • For financial models, cite model inputs in cell comments.
  • For tabular data sourced externally, add a source column when each row represents a separate item.
  • 在电子表格中使用纯文本 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.
  • Never overwrite established formatting unless the user explicitly asks for a redesign.
  • 如果可能,在修改前渲染并检查提供的电子表格。
  • 完全保留现有格式和样式。
  • 新填充的单元格如果原本为空,应匹配其样式。
  • 除非用户明确要求重新设计,否则绝不覆盖既定格式。

Formatting requirements (new or unstyled spreadsheets)

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

  • Use appropriate number and date formats.
  • Dates should render as dates, not plain numbers.
  • Percentages should usually default to one decimal place unless the data calls for something else.
  • Currencies should use the appropriate currency format.
  • Headers should be visually distinct from raw inputs and derived cells.
  • Use fill colors, borders, spacing, and merged cells sparingly and intentionally.
  • Set row heights and column widths so content is readable without excessive whitespace.
  • Do not apply borders around every filled cell.
  • Group related calculations and make totals simple sums of the cells above them.
  • Add whitespace to separate sections.
  • Ensure text does not spill into adjacent cells.
  • Avoid unsupported spreadsheet data-table features such as
    =TABLE
    .
  • 使用适当的数字和日期格式。
  • 日期应呈现为日期,而不是普通数字。
  • 百分比通常应默认保留一位小数,除非数据另有要求。
  • 货币应使用适当的货币格式。
  • 表头应在视觉上与原始输入和派生单元格区分开来。
  • 谨慎且有意地使用填充颜色、边框、间距和合并单元格。
  • 设置行高和列宽,使内容易于阅读,同时避免过多空白。
  • 不要为每个已填充的单元格添加边框。
  • 对相关计算进行分组,使总计成为上方单元格的简单求和。
  • 使用空白分隔不同部分。
  • 确保文本不会溢出到相邻单元格。
  • 避免使用不受支持的电子表格数据表功能,例如
    =TABLE
    。

Color conventions (if no style guidance)

颜色约定(没有样式指导时)

  • Blue: user input
  • Black: formulas and derived values
  • Green: linked or imported values
  • Gray: static constants
  • Orange: review or caution
  • Light red: error or flag
  • Purple: control or logic
  • Teal: visualization anchors and KPI highlights
  • 蓝色:用户输入
  • 黑色:公式和派生值
  • 绿色:链接或导入的值
  • 灰色:静态常量
  • 橙色:需要审查或谨慎处理
  • 浅红色:错误或标记
  • 紫色:控制项或逻辑
  • 蓝绿色:可视化锚点和 KPI 重点突出

Finance-specific requirements

财务专用要求

  • Format zeros as
    -
    .
  • Negative numbers should be red and in parentheses.
  • Format multiples as
    5.2x
    .
  • Always specify units in headers (for example,
    Revenue ($mm)
    ).
  • Cite sources for all raw inputs in cell comments.
  • For new financial models with no user-specified style, use blue text for hardcoded inputs, black for formulas, green for internal workbook links, red for external links, and yellow fill for key assumptions that need attention.
  • 将零格式化为
    -
    。
  • 负数应使用红色并置于括号内。
  • 将倍数格式化为
    5.2x
    。
  • 始终在表头中指定单位(例如,
    Revenue ($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 and 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 should be left-aligned.
  • Indent submetrics under their parent line items.
如果电子表格是投行风格的模型(LBO、DCF、三表、估值):
  • 总计应直接对上方范围求和。
  • 隐藏网格线,并在相关列的汇总行上方使用水平边框。
  • 分区标题应使用深色填充和白色文本的合并单元格。
  • 数值数据的列标签应右对齐;行标签应左对齐。
  • 将子指标缩进排列在其父级项目下方。