跳到正文
Skillpedia
PDF、Word 与幻灯片7.8k · #12872

excel-creation-fallback

它能做什么

这项技能说明如何用 openpyxl 制作 .xlsx 文件,以及代码沙箱无法运行时该怎么办。它适合需要按特定列、格式或汇总制作电子表格的人。

适用场景

  • ✓当代码沙箱因 openpyxl 的导入错误而失败的时候。
  • ✓当我需要带有表头、格式和合计的电子表格的时候。
  • ✓当多次在沙箱中保存电子表格的尝试都失败的时候。

技能链接

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/excel-creation-fallback/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/excel-creation-fallback/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我制作一个 Excel 文件,包含日期、指标和数值三列,表头加粗,并附上合计行。”

每周 5 个新技能,1 分钟读完。

工作原理

AI 首先尝试在沙箱中用 openpyxl 制作文件。如果失败,就把清晰的说明交给 shell 辅助工具,由它安装所需的库并保存文件。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Excel File Creation Fallback

When execute_code_sandbox fails for openpyxl or Excel operations, delegate to shell_agent which can autonomously handle dependency and environment issues.

When to Use

  • execute_code_sandbox fails with import errors for openpyxl or related libraries
  • The sandbox environment lacks required dependencies
  • You need to create or modify Excel files with complex requirements
  • Repeated sandbox execution failures for file I/O operations

Steps

Step 1: Attempt with execute_code_sandbox first

Try creating the Excel file using Python's openpyxl library in the code sandbox:

from openpyxl import Workbook

wb = Workbook()
ws = wb.active
ws.append(['Column1', 'Column2', 'Column3'])
wb.save('output.xlsx')

Step 2: If it fails, switch to shell_agent

Delegate the task to shell_agent with a clear, comprehensive task description:

Create an Excel file named 'output.xlsx' with the following structure:
- Sheet 1: Data with columns [Date, Metric, Value]
- Include sample data rows with realistic values
- Apply basic formatting (bold headers, cell borders)
- Add a summary section with totals or averages
- Save the file in the current directory

Step 3: Let shell_agent handle the environment

The shell_agent will:

  • Decide whether to use Python or Bash
  • Install dependencies if needed (e.g., pip install openpyxl)
  • Write and execute the code
  • Automatically retry and fix errors (up to several rounds)
  • Confirm the file was created successfully

Example Task Descriptions

Basic Excel file:

Create an Excel file named 'sales_report.xlsx' with headers: Date, Product, Quantity, Price, Total. Add 10 sample rows of data and a formula column for Total (Quantity * Price).

Complex Excel with formatting:

Create an Excel file with multiple sheets:
- Sheet 'Summary': Key metrics and totals
- Sheet 'Details': Full transaction data with columns [ID, Date, Customer, Amount, Status]
- Apply conditional formatting to highlight amounts over 1000
- Add borders to all cells and bold headers

Tiered pricing structure:

Create an Excel file with a tiered pricing table:
- Column A: Quantity thresholds (0, 100, 500, 1000)
- Column B: Unit price at each tier
- Column C: Discount percentage (e.g., 15% discount over 1000 units)
- Include a financial summary section with projections

Why This Pattern Works

shell_agent has several advantages over execute_code_sandbox for file creation tasks:

Feature execute_code_sandbox shell_agent
Dependency installation Manual/preset only Autonomous
Error recovery Returns error Auto-retries and fixes
Tool selection Python only Python, Bash, or other
Filesystem access Sandbox-limited Full workspace access
Verification None Can verify file creation

Troubleshooting

If shell_agent also struggles:

  1. Be more specific - Include exact column names, data types, and formatting requirements
  2. Provide sample data - Include example rows to clarify expected output
  3. Break it down - For complex files, request creation in stages
  4. Check permissions - Ensure the target directory is writable

Alternative Approaches

If shell_agent is unavailable or unsuitable:

  • Use run_shell with explicit commands (if you know the exact syntax)
  • Check for alternative libraries (xlsxwriter, pandas with openpyxl engine)
  • Use CSV as intermediate format, then convert to Excel
常见问题

什么是 openpyxl?

它是一个用于创建和编辑 Excel 文件的 Python 库。

谁来安装缺失的软件包?

如果缺少 openpyxl 等依赖项,shell 辅助工具可以安装它们。

请求中应包含什么?

对工作表、列、示例行、格式以及保存位置的清晰描述。

详情

作者的原始描述

Use shell_agent as fallback when execute_code_sandbox fails for Excel file operations

repo: HKUDS/AgentPilot

热度

GitHub 星标
7.8k
排名
#12872
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能