openpyxl-sandbox-workaround
यह क्या करती है
यह स्किल स्प्रेडशीट के कामों के लिए बैकअप है, जहाँ कोड सैंडबॉक्स विफल हो। यह openpyxl कोड सीधे शेल से चलाती है। यह उन लोगों के लिए है जिन्हें सामान्य सैंडबॉक्स विफल होने पर भी Excel फ़ाइल चाहिए।
कब इस्तेमाल करें
- ✓जब openpyxl या स्प्रेडशीट के काम पर कोड सैंडबॉक्स बार-बार विफल हो।
- ✓जब एरर वर्कबुक बनाने, सेल में लिखने या सहेजने से जुड़े हों।
- ✓जब मुझे एक मल्टी-स्टेप स्प्रेडशीट काम चाहिए, जो मौजूदा फ़ाइल लोड करके नया डेटा लिखे।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/openpyxl-sandbox-workaround/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरी स्प्रेडशीट बनाते समय सैंडबॉक्स बार-बार विफल हो रहा है। कृपया वही कोड शेल से चलाइए और फ़ाइल सहेजिए।”
हर हफ़्ते 5 नई skills, 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_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
अक्सर पूछे जाने वाले सवाल
यह तरीका क्यों मदद करता है?
गाइड के अनुसार सैंडबॉक्स में संगतता की समस्याएँ हो सकती हैं, जिनसे शेल से सीधे 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
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
agentpilot
7.8kआपके एजेंट को AgentPilot से प्रोजेक्ट को चरण-दर-चरण सुधारने में मदद करती है, जिसमें बदलाव सुझाए, परखे और स्कोर किए जाते हैं।
openspace
7.8kआपके एजेंट को OpenSpace सेट करने में मदद करती है, जो एजेंट स्किल्स सहेजता और वापस लाता है, और MCP के ज़रिए आपके AI ऐप से जुड़ता है।
rsi-arena
7.8kआपके एजेंट को AIME और Terminal-Bench जैसे मानक AI बेंचमार्क टेस्ट सेट करने और चलाने में मदद करती है, ताकि सुधार के तरीकों की तुलना हो सके।
experiment-guide
7.8kआपके एजेंट को छोटे प्रयोग बनाने, उनके नतीजे पढ़ने और जाँच के दौरान उपयोगी निष्कर्ष लिखने में मदद करती है।
मिलती-जुलती skills
feishu-doc
394kयह आपके एजेंट को document टूल से Feishu क्लाउड दस्तावेज़ पढ़ने, बनाने और बदलने में मदद करती है, जिसमें टेक्स्ट, इमेज और टेबल शामिल हैं।
feishu-drive
394kयह आपके एजेंट को बॉट के साथ साझा किए गए Feishu क्लाउड फ़ोल्डर में फ़ाइलें देखने, व्यवस्थित करने और उन पर टिप्पणी करने देती है।
feishu-perm
394kयह आपके एजेंट को Feishu फ़ाइल तक किसकी पहुंच है, यह जांचने और बदलने देती है, और आपके अनुरोध के लिए सबसे छोटी अनुमति चुनती है।