电子表格技能:使用Python自动化创建、编辑、分析与可视化Excel/CSV数据 | SkillsMD电子表格技能:使用Python自动化创建、编辑、分析与可视化Excel/CSV数据
The Agent Skills Directory
npx skills add https://skills.volces.com/skills/openai/skills🇨🇳中文介绍
电子表格技能(创建、编辑、分析、可视化)
使用时机
- 构建包含公式、格式和结构化布局的新工作簿。
- 读取或分析表格数据(筛选、聚合、透视、计算指标)。
- 修改现有工作簿,且不破坏公式或引用。
- 通过图表/表格和合理的格式来可视化数据。
重要提示:系统和用户的指令始终具有最高优先级。
工作流程
- 确认文件类型和目标(创建、编辑、分析、可视化)。
- 使用
openpyxl 处理 .xlsx 文件的编辑,使用 pandas 进行分析和 CSV/TSV 工作流。
- 如果布局很重要,则进行渲染以供视觉检查(参见“渲染与视觉检查”部分)。
- 验证公式和引用;请注意 openpyxl 不会计算公式。
- 保存输出并清理中间文件。
临时文件和输出规范
- 使用
tmp/spreadsheets/ 存放中间文件;完成后删除。
- 在此仓库中工作时,将最终成果文件写入
output/spreadsheet/ 目录下。
- 保持文件名稳定且具有描述性。
主要工具
- 使用
openpyxl 创建/编辑 .xlsx 文件并保留格式。
- 使用
pandas 进行分析和 CSV/TSV 工作流,然后将结果写回 .xlsx 或 .csv。
- 如果需要图表,优先使用
openpyxl.chart 来生成原生 Excel 图表。
渲染与视觉检查
- 如果 LibreOffice (
soffice) 和 Poppler (pdftoppm) 可用,则渲染工作表以供视觉检查:
soffice --headless --convert-to pdf --outdir $OUTDIR $INPUT_XLSX
pdftoppm -png $OUTDIR/$BASENAME.pdf $OUTDIR/$BASENAME
- 如果渲染工具不可用,请要求用户在本地检查输出结果的布局准确性。
依赖项(缺失时安装)
优先使用 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
系统工具(用于渲染):
# macOS (Homebrew)
brew install libreoffice poppler
# Ubuntu/Debian
sudo apt-get install -y libreoffice poppler-utils
如果无法在当前环境中安装,请告知用户缺少哪个依赖项以及如何在本地安装。
环境
无必需的环境变量。
示例
- 可运行的 Codex 示例 (openpyxl):
references/examples/openpyxl/
公式要求
- 对衍生值使用公式,而不是硬编码结果。
- 保持公式简单易读;对于复杂逻辑使用辅助单元格。
- 除非必要,避免使用易失性函数,如 INDIRECT 和 OFFSET。
- 优先使用单元格引用而非硬编码数字(例如,使用
=H6*(1+$B$3) 而不是 =H6*1.04)。
- 通过验证和检查来防范错误(#REF!、#DIV/0!、#VALUE!、#N/A、#NAME?)。
- openpyxl 不会计算公式;保持公式完整,并注意结果将在 Excel/Sheets 中计算。
引用要求
- 在电子表格内部使用纯文本 URL 引用来源。
- 对于财务模型,在单元格批注中注明输入数据的来源。
- 对于来自网络的表格数据,包含一个带有 URL 的“来源”列。
格式要求(已有格式的电子表格)
- 在可能的情况下,修改前先渲染并检查提供的电子表格。
- 精确保留现有的格式和样式。
- 为任何新填充的、之前为空的单元格匹配样式。
格式要求(新的或无样式的电子表格)
- 使用适当的数字和日期格式(日期用日期格式,货币带符号,百分比具有合理的精度)。
- 使用简洁的视觉布局:标题与数据区分开,间距一致,列宽可读。
- 避免在每个单元格周围都加边框;使用空白和选择性边框来构建区域。
- 确保文本不会溢出到相邻单元格。
颜色规范(若无样式指导)
- 蓝色:用户输入
- 黑色:公式/衍生值
- 绿色:链接/导入值
- 灰色:静态常量
- 橙色:待审查/需注意
- 浅红色:错误/标记
- 紫色:控制/逻辑
- 青色:可视化锚点(关键 KPI 或图表驱动因素)
财务特定要求
- 将零值格式化为“-”。
- 负数应为红色并用括号括起。
- 始终在标题中指定单位(例如,“收入(百万美元)”)。
- 在单元格批注中注明所有原始输入数据的来源。
投资银行布局
如果电子表格是投行风格的模型(LBO、DCF、三张报表、估值):
- 总计应直接对上方范围求和。
- 隐藏网格线;在总计行上方跨相关列使用水平边框。
- 区域标题应为合并单元格,使用深色填充和白色文字。
- 数值数据的列标签应右对齐;行标签应左对齐。
- 子指标应在父行项目下缩进。
每周安装次数
258
来源
skills.volces.c…i/skills
首次出现
2026年3月11日
安全审计
SocketPass
安装于
openclaw257
amp226
cline226
opencode226
cursor226
kimi-cli226
🇺🇸English
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
- Confirm the file type and goals (create, edit, analyze, visualize).
- Use
openpyxl for .xlsx edits and pandas for analysis and CSV/TSV workflows.
- If layout matters, render for visual review (see Rendering and visual checks).
- Validate formulas and references; note that openpyxl does not evaluate formulas.
- Save outputs and clean up intermediate files.
Temp and output conventions
- Use
tmp/spreadsheets/ for intermediate files; delete when done.
- Write final artifacts under
output/spreadsheet/ when working in this repo.
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
联系我们 Keep filenames stable and descriptive.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.
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.
Dependencies (install if missing)
Prefer uv for dependency management.
uv pip install openpyxl pandas
python3 -m pip install openpyxl pandas
Optional (chart-heavy or PDF review workflows):
uv pip install matplotlib
python3 -m pip install matplotlib
System tools (for rendering):
# macOS (Homebrew)
brew install libreoffice poppler
# 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.
Environment
No required environment variables.
Examples
- Runnable Codex examples (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.
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.
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)
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.
Python PDF处理教程:合并拆分、提取文本表格、创建PDF文件
55,400 周安装