excel-heredoc-workaround
하는 일
이 스킬은 코드 샌드박스에 문제가 있을 때 openpyxl로 Excel 통합 문서를 만드는 우회 방법입니다. 구조화된 제목과 스타일이 있는 스프레드시트가 필요한 사람에게 맞습니다.
사용하는 경우
- ✓openpyxl 문제로 샌드박스에서 .xlsx 파일 만들기가 실패할 때.
- ✓스타일이 있는 제목, 테두리, 일정표 형식의 스프레드시트가 필요할 때.
- ✓이 컴퓨터의 셸에서 Python을 직접 실행할 수 있는 경우.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/excel-heredoc-workaround/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“스타일이 적용된 제목과 테두리가 있는 Excel 일정표를 만들어 주세요. 샌드박스가 실패하니 셸에서 실행해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
AI는 먼저 샌드박스를 시도하고, 실패하면 셸에서 openpyxl 스크립트를 직접 실행해 통합 문서를 만들고, 제목에 스타일을 적용한 뒤 파일을 저장합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Excel Heredoc Workaround
Purpose
When creating Excel files with openpyxl, execute_code_sandbox may fail due to environment issues. This skill provides a robust workaround: fall back to run_shell with inline Python heredoc scripts to create properly formatted spreadsheets with styling.
When to Use
- You need to create
.xlsxfiles with openpyxl execute_code_sandboxfails with openpyxl-related errors- You need styling, formatting, or complex spreadsheet features
- Direct shell execution with Python heredoc is available
Step-by-Step Instructions
Step 1: Attempt execute_code_sandbox First
Try creating the Excel file using execute_code_sandbox:
from openpyxl import Workbook
from openpyxl.styles import Font, Alignment, PatternFill
wb = Workbook()
ws = wb.active
ws.title = "Data"
# Add data and styling
ws['A1'] = "Header"
ws['A1'].font = Font(bold=True)
wb.save("output.xlsx")
print("ARTIFACT_PATH:output.xlsx")
Step 2: If Sandbox Fails, Use run_shell with Heredoc
When execute_code_sandbox fails, switch to run_shell with a Python heredoc:
python3 << 'EOF'
from openpyxl import Workbook
from openpyxl.styles import Font, Alignment, PatternFill, Border, Side
# Create workbook
wb = Workbook()
ws = wb.active
ws.title = "Schedule"
# Add headers with styling
headers = ["Task", "Date", "Status", "Priority"]
for col, header in enumerate(headers, 1):
cell = ws.cell(row=1, column=col, value=header)
cell.font = Font(bold=True, size=12)
cell.fill = PatternFill(start_color="4472C4", end_color="4472C4", fill_type="solid")
cell.font = Font(bold=True, color="FFFFFF")
cell.alignment = Alignment(horizontal="center")
# Add data rows
data = [
["Cleanup Zone A", "2024-01-15", "Pending", "High"],
["Cleanup Zone B", "2024-01-16", "Complete", "Medium"],
]
for row_idx, row_data in enumerate(data, 2):
for col_idx, value in enumerate(row_data, 1):
cell = ws.cell(row=row_idx, column=col_idx, value=value)
cell.alignment = Alignment(horizontal="left")
# Adjust column widths
for col in ws.columns:
max_length = 0
column = col[0].column_letter
for cell in col:
try:
if len(str(cell.value)) > max_length:
max_length = len(str(cell.value))
except:
pass
ws.column_dimensions[column].width = max_length + 2
# Save the file
wb.save("Cleanup_Schedule.xlsx")
print("Created Cleanup_Schedule.xlsx successfully")
EOF
Step 3: Verify File Creation
After running the heredoc script, verify the file was created:
ls -lh *.xlsx
Step 4: Optional - Read Back to Confirm
Use read_file to confirm the Excel file is valid:
read_file with filetype="xlsx", file_path="Cleanup_Schedule.xlsx"
Key Advantages
| Aspect | execute_code_sandbox | run_shell heredoc |
|---|---|---|
| Reliability | May fail with openpyxl | More stable execution |
| Styling support | Limited | Full openpyxl support |
| File output | Via ARTIFACT_PATH | Direct file write |
| Debugging | Limited output | Full stdout/stderr |
Common Styling Patterns
Bold Headers with Colored Background
from openpyxl.styles import Font, PatternFill
header_fill = PatternFill(start_color="4472C4", end_color="4472C4", fill_type="solid")
header_font = Font(bold=True, color="FFFFFF", size=12)
cell = ws.cell(row=1, column=1, value="Header")
cell.fill = header_fill
cell.font = header_font
Alternating Row Colors
from openpyxl.styles import PatternFill
gray_fill = PatternFill(start_color="D9D9D9", end_color="D9D9D9", fill_type="solid")
for row in range(2, ws.max_row + 1):
if row % 2 == 0:
for col in range(1, ws.max_column + 1):
ws.cell(row=row, column=col).fill = gray_fill
Borders and Alignment
from openpyxl.styles import Border, Side, Alignment
thin_border = Border(
left=Side(style='thin'),
right=Side(style='thin'),
top=Side(style='thin'),
bottom=Side(style='thin')
)
for row in ws.iter_rows():
for cell in row:
cell.border = thin_border
cell.alignment = Alignment(horizontal="center", vertical="center")
Troubleshooting
Issue: File not created after heredoc execution
- Fix: Check stdout for Python errors; ensure working directory is correct
Issue: openpyxl not found
- Fix: Install with
pip install openpyxlbefore running her
자주 묻는 질문
샌드박스를 먼저 시도하나요?
네, 가이드는 샌드박스를 먼저 시도하고 실패할 때만 전환하라고 안내합니다.
어떤 스타일을 보여 주나요?
예제에는 굵은 글씨, 채우기 색, 정렬, 테두리가 들어 있습니다.
저장된 파일은 어떻게 찾나요?
예제는 저장 후 경로 표시를 출력하므로 결과 파일을 찾을 수 있습니다.
상세 정보
작성자의 원본 설명
Create Excel files with openpyxl by falling back to run_shell with inline Python heredoc when execute_code_sandbox fails
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12875
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.
비슷한 스킬
feishu-doc
394k에이전트가 문서 도구를 사용해 텍스트, 이미지, 표를 포함한 Feishu 클라우드 문서를 읽고, 만들고, 편집하도록 돕습니다.
feishu-drive
394k에이전트가 봇과 공유된 Feishu 클라우드 폴더의 파일을 찾아보고, 정리하고, 댓글을 달도록 돕습니다.
feishu-perm
394k에이전트가 요청을 충족하는 가장 작은 권한을 골라, Feishu 파일에 누가 접근할 수 있는지 확인하고 바꾸도록 돕습니다.