openpyxl-sandbox-workaround
Skill này làm gì
Skill này là phương án dự phòng cho các tác vụ bảng tính khi sandbox code thất bại. Nó chạy code openpyxl trực tiếp từ shell thay thế. Dành cho người cần tạo tệp Excel khi sandbox thông thường không hoạt động.
Khi nào nên dùng
- ✓Khi sandbox code liên tục thất bại với một tác vụ openpyxl hoặc bảng tính.
- ✓Khi lỗi liên quan đến việc tạo sổ tính, ghi ô hoặc lưu.
- ✓Khi tôi cần một tác vụ bảng tính nhiều bước, tải một tệp có sẵn và ghi dữ liệu mới.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/openpyxl-sandbox-workaround/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Sandbox liên tục thất bại khi tạo bảng tính của tôi. Hãy chạy cùng đoạn code đó từ shell và lưu tệp.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI viết một script Python nội tuyến trong heredoc shell, tạo hoặc tải sổ tính, thêm dữ liệu, lưu tệp và in một thông báo xác nhận.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Openpyxl Sandbox Workaround
When to Use
Use this pattern when execute_code_sandbox repeatedly fails for openpyxl or spreadsheet manipulation tasks. The sandbox environment may have compatibility issues with certain openpyxl operations, but running Python directly via run_shell often succeeds.
Common Failure Indicators
execute_code_sandboxreturns errors related to openpyxl imports or operations- Multiple retry attempts fail with similar errors
- Errors mention workbook creation, cell writing, or file saving issues
The Workaround Pattern
Instead of using execute_code_sandbox, use run_shell with an inline Python script:
python3 << 'EOF'
from openpyxl import Workbook
from openpyxl.utils import get_column_letter
# Your openpyxl code here
wb = Workbook()
ws = wb.active
ws.title = "Sheet1"
# Add data
ws['A1'] = 'Header'
ws['B1'] = 'Value'
# Save file
wb.save('output.xlsx')
print('File created successfully')
EOF
Multi-Step Spreadsheet Tasks
For complex operations involving multiple files or data processing:
python3 << 'EOF'
from openpyxl import Workbook, load_workbook
import os
# Load existing workbook if needed
if os.path.exists('input.xlsx'):
wb = load_workbook('input.xlsx')
ws = wb.active
# Process data...
# Create new workbook
wb = Workbook()
ws = wb.active
# Add data with proper formatting
for row_idx, row_data in enumerate(data, start=1):
for col_idx, value in enumerate(row_data, start=1):
ws.cell(row=row_idx, column=col_idx, value=value)
# Auto-adjust column widths
for column in ws.columns:
max_length = 0
column_letter = get_column_letter(column[0].column)
for cell in column:
try:
if len(str(cell.value)) > max_length:
max_length = len(str(cell.value))
except:
pass
adjusted_width = min(max_length + 2, 50)
ws.column_dimensions[column_letter].width = adjusted_width
wb.save('output.xlsx')
EOF
Best Practices
- Use heredoc syntax: The
<< 'EOF'pattern prevents variable expansion issues - Print success messages: Always include print statements to confirm completion
- Handle file paths: Use absolute paths or ensure you're in the correct working directory
- Validate output: After creation, verify the file exists and has expected content
- Error handling: Add try/except blocks for robustness in complex scripts
Verification Step
After running the script, verify the file was created:
ls -la *.xlsx
Or check file details:
python3 << 'EOF'
from openpyxl import load_workbook
wb = load_workbook('output.xlsx')
print(f"Sheets: {wb.sheetnames}")
print(f"Active sheet: {wb.active.title}")
EOF
When to Fall Back to This Pattern
- First
execute_code_sandboxattempt fails with openpyxl errors - Error persists after 1-2 retries
- Task is time-sensitive and needs a reliable solution
- The operation is straightforward file creation/modification
Limitations
- Output is limited to stdout/stderr (no direct artifact download from run_shell)
- Files are created in the current working directory
- More verbose than execute_code_sandbox for simple operations
Câu hỏi thường gặp
Vì sao cách này hữu ích?
Hướng dẫn nói sandbox có thể gặp vấn đề tương thích mà việc chạy Python trực tiếp từ shell tránh được.
Có mở được một sổ tính đã có không?
Có. Ví dụ tải một sổ tính đầu vào nếu nó tồn tại trước khi tạo nội dung mới.
Làm sao biết đã thành công?
Script in thông báo thành công, và có thể kiểm tra tệp đã lưu.
Chi tiết
Mô tả gốc của tác giả
Use run_shell with inline Python as a fallback when execute_code_sandbox fails for openpyxl/spreadsheet operations
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #12902
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
Skill tương tự
feishu-doc
394kGiúp agent của bạn đọc, tạo và sửa tài liệu đám mây Feishu, gồm văn bản, hình ảnh và bảng, bằng công cụ tài liệu.
feishu-drive
394kCho phép agent của bạn duyệt, sắp xếp và bình luận các file trong một thư mục đám mây Feishu đã được chia sẻ với bot.
feishu-perm
394kGiúp agent của bạn kiểm tra và thay đổi ai có quyền truy cập một file Feishu, chọn quyền nhỏ nhất đáp ứng yêu cầu của bạn.