openai-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.
  • 使用
    openpyxl
    创建/编辑.xlsx文件并保留格式。
  • 使用
    pandas
    进行分析和CSV/TSV处理,然后将结果写回.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 the agent examples (openpyxl):
    references/examples/openpyxl/
  • 可运行的Agent示例(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/Sheets中计算。

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.
  • 零值格式化为“-”。
  • 负数应为红色并加括号。
  • 表头中始终指定单位(例如:“收入(百万美元)”)。
  • 在单元格注释中注明所有原始输入的来源。

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、三表模型、估值):
  • 总计应直接对上方区域求和。
  • 隐藏网格线;在总计行上方的相关列添加水平边框。
  • 分区表头应为合并单元格,深色填充,白色文本。
  • 数值数据的列标签右对齐;行标签左对齐。
  • 子指标在父级项目下缩进。

When NOT to Use

不适用场景

<!-- TODO: review -->
<!-- TODO: 待审核 -->