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。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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_sandboxfails 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:
- Be more specific - Include exact column names, data types, and formatting requirements
- Provide sample data - Include example rows to clarify expected output
- Break it down - For complex files, request creation in stages
- Check permissions - Ensure the target directory is writable
Alternative Approaches
If shell_agent is unavailable or unsuitable:
- Use
run_shellwith 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
评论
- …
同一仓库的更多技能
agentpilot
7.8k帮你的智能体准备任务并运行 AgentPilot 循环,逐步改进项目:循环会提出修改、测试修改并为其打分。
openspace
7.8k帮你的智能体设置 OpenSpace,这是一个用于存储和获取智能体技能的工具,并通过 MCP 将其连接到你的 AI 应用。
rsi-arena
7.8k帮你的智能体设置并运行标准 AI 基准测试,例如 AIME 和 Terminal-Bench,用来比较不同的改进方法。
experiment-guide
7.8k帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。