reliable-excel-workbook-creation
यह क्या करती है
यह स्किल AI एजेंट को एक साफ़ स्क्रिप्ट में Python से जटिल Excel फ़ाइलें बनाने का तरीका दिखाती है। यह उन लोगों के लिए है जिन्हें डेटा और फ़ॉर्मेटिंग वाली कई शीट वाली वर्कबुक चाहिए।
कब इस्तेमाल करें
- ✓जब आपको कई शीट, डेटा और फ़ॉर्मेटिंग वाली Excel वर्कबुक चाहिए।
- ✓जब फ़ाइल रीडर मौजूदा XLSX फ़ाइल ठीक से न खोल पाए।
- ✓जब कई चरणों वाला वर्कबुक काम सैंडबॉक्स में विफल हो।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/reliable-excel-workbook-creation/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे बजट के लिए तीन शीट वाली एक Excel वर्कबुक बनाइए, जिसके हेडर बोल्ड हों। ऐसी स्क्रिप्ट इस्तेमाल कीजिए जो उसे मेरे वर्कस्पेस में सहेजे।”
हर हफ़्ते 5 नई skills, 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
- अपडेट की गई
- 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 फ़ाइल तक किसकी पहुंच है, यह जांचने और बदलने देती है, और आपके अनुरोध के लिए सबसे छोटी अनुमति चुनती है।