reliable-excel-workbook-creation
하는 일
이 스킬은 하나의 깔끔한 Python 스크립트로 복잡한 Excel 파일을 만드는 방법을 AI 에이전트에게 보여 줍니다. 데이터와 서식이 있는 여러 시트짜리 통합 문서가 필요한 사람에게 맞습니다.
사용하는 경우
- ✓데이터와 서식이 있는 여러 시트짜리 Excel 통합 문서가 필요할 때.
- ✓파일 읽기 도구가 기존 XLSX 파일을 제대로 열지 못하는 경우.
- ✓샌드박스에서 여러 단계로 된 통합 문서 작업이 실패할 때.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/reliable-excel-workbook-creation/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 예산을 위해 시트 세 개짜리 Excel 통합 문서를 만들어 주세요. 제목은 굵게 해 주세요. 작업 공간에 저장하는 스크립트를 써 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 작업 공간 폴더로 이동한 뒤, 셸에서 Python 스크립트 하나를 실행합니다. 이 스크립트는 통합 문서를 만들고, 데이터를 넣고, 서식을 적용하고, 전체 경로로 저장합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Reliable Excel Workbook Creation via Shell
When to Use This Pattern
Use this technique when you need to:
- Create complex Excel workbooks with multiple sheets
- Perform multi-step workbook operations (create, populate, format, save)
- Work with XLSX files that
read_filecannot handle properly - Avoid failures from
execute_code_sandboxon persistent file operations
Avoid: read_file for XLSX files, execute_code_sandbox for multi-step workbook creation
Core Pattern
cd /workspace && python3 << 'EOF'
from openpyxl import Workbook
# Your Excel operations here
wb = Workbook()
# ... create sheets, add data, save
wb.save('/workspace/filename.xlsx')
EOF
Step-by-Step Instructions
Step 1: Change to Workspace Directory
Always start with cd /workspace && to ensure file paths resolve correctly.
Step 2: Use Heredoc with Single-Quoted EOF
Use << 'EOF' (single quotes) to prevent shell variable expansion within the Python code.
Step 3: Write Complete Python Script
Include all imports, workbook creation, data population, and save operations in one script.
Step 4: Use Absolute Paths for Save Operations
Always save with full path: /workspace/your_filename.xlsx
Complete Example
cd /workspace && python3 << 'EOF'
from openpyxl import Workbook
from openpyxl.styles import Font, Alignment, PatternFill
# Create workbook
wb = Workbook()
# Create multiple sheets
sheets = ['Summary', 'Data', 'Analysis', 'Settings']
for sheet_name in sheets:
wb.create_sheet(title=sheet_name)
# Remove default sheet if needed
if 'Sheet' in wb.sheetnames:
del wb['Sheet']
# Populate data
ws = wb['Data']
ws['A1'] = 'Item'
ws['B1'] = 'Value'
ws['A2'] = 'Revenue'
ws['B2'] = 100000
# Apply formatting
header_font = Font(bold=True)
for cell in ws['1:1']:
cell.font = header_font
# Save workbook
wb.save('/workspace/report.xlsx')
print('Workbook created successfully: /workspace/report.xlsx')
EOF
Why This Works
| Approach | Problem | Solution |
|---|---|---|
read_file |
Cannot parse XLSX binary format | Don't use for Excel files |
execute_code_sandbox |
File persistence issues, multi-step failures | Use run_shell instead |
run_shell with heredoc |
✓ Reliable, full control, persistent files | Use this pattern |
Common Operations
Create Multi-Sheet Workbook
cd /workspace && python3 << 'EOF'
from openpyxl import Workbook
wb = Workbook()
sheet_names = ['Sheet1', 'Sheet2', 'Sheet3']
for name in sheet_names:
wb.create_sheet(title=name)
wb.save('/workspace/multi_sheet.xlsx')
EOF
Read and Modify Existing Workbook
cd /workspace && python3 << 'EOF'
from openpyxl import load_workbook
wb = load_workbook('/workspace/existing.xlsx')
ws = wb.active
ws['A1'] = 'Updated Value'
wb.save('/workspace/existing.xlsx')
EOF
Add Formulas
cd /workspace && python3 << 'EOF'
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws['A1'] = 100
ws['A2'] = 200
ws['A3'] = '=SUM(A1:A2)'
wb.save('/workspace/with_formulas.xlsx')
EOF
Troubleshooting
- File not found: Ensure you use
/workspace/prefix in all paths - Permission errors: Verify workspace directory is writable
- Module not found: openpyxl is pre-installed in the environment
- Heredoc issues: Use single-quoted
'EOF'to prevent shell interpretation
Best Practices
- Always use absolute paths (
/workspace/filename.xlsx) - Single-quoted heredoc (
<< 'EOF') prevents variable expansion - Complete script in one heredoc - avoid splitting operations
- Print confirmation after save to verify success
- Handle exceptions for production scripts
자주 묻는 질문
저장 경로를 전체로 쓰는 이유는 무엇인가요?
전체 경로를 쓰면 파일이 다른 폴더가 아니라 예상한 위치에 저장되도록 보장할 수 있습니다.
스크립트가 셀 서식을 지정할 수 있나요?
네, 스킬의 예제는 통합 문서의 글꼴, 채우기, 정렬을 설정합니다.
XLSX에는 왜 파일 읽기 도구를 쓰지 않나요?
스킬은 그 도구가 XLSX 파일을 제대로 다루지 못할 때가 있어서 파일을 직접 쓴다고 설명합니다.
상세 정보
작성자의 원본 설명
Use run_shell with cd and heredoc syntax for complex Excel operations when read_file fails on XLSX or execute_code_sandbox fails on multi-step workbook creation
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12966
- 라이선스
- 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 파일에 누가 접근할 수 있는지 확인하고 바꾸도록 돕습니다.