본문으로 건너뛰기
Skillpedia
PDF, Word, 슬라이드7.8k · #12902

openpyxl-sandbox-workaround

하는 일

이 스킬은 코드 샌드박스가 실패하는 스프레드시트 작업의 예비 방법입니다. 샌드박스 대신 셸에서 openpyxl 코드를 직접 실행합니다. 평소 샌드박스가 실패할 때 Excel 파일이 필요한 사람에게 맞습니다.

사용하는 경우

  • ✓openpyxl이나 스프레드시트 작업에서 코드 샌드박스가 반복해서 실패할 때.
  • ✓오류가 통합 문서 생성, 셀 쓰기 또는 저장과 관련될 때.
  • ✓기존 파일을 불러와 새 데이터를 쓰는 여러 단계 스프레드시트 작업이 필요한 경우.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/openpyxl-sandbox-workaround/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/openpyxl-sandbox-workaround/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“샌드박스가 스프레드시트를 만들 때 계속 실패합니다. 같은 코드를 셸에서 실행하고 파일을 저장해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI는 셸 heredoc에 인라인 Python 스크립트를 쓰고, 통합 문서를 만들거나 불러오고, 데이터를 추가한 뒤 파일을 저장하고 확인 메시지를 출력합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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_sandbox returns 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

  1. Use heredoc syntax: The << 'EOF' pattern prevents variable expansion issues
  2. Print success messages: Always include print statements to confirm completion
  3. Handle file paths: Use absolute paths or ensure you're in the correct working directory
  4. Validate output: After creation, verify the file exists and has expected content
  5. 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_sandbox attempt 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
자주 묻는 질문

이 방법이 왜 도움이 되나요?

가이드는 샌드박스의 호환성 문제를, 셸에서 Python을 직접 실행하면 피할 수 있다고 설명합니다.

기존 통합 문서를 열 수 있나요?

네, 예제는 입력 통합 문서가 있으면 불러온 뒤 새 내용을 만듭니다.

작동했는지 어떻게 알 수 있나요?

스크립트가 성공 메시지를 출력하며, 저장된 파일도 확인할 수 있습니다.

상세 정보

작성자의 원본 설명

Use run_shell with inline Python as a fallback when execute_code_sandbox fails for openpyxl/spreadsheet operations

repo: HKUDS/AgentPilot

인기도

GitHub 스타
7.8k
순위
#12902
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬