Requirements for Outputs
All Excel files
Professional Font
- Use a consistent, professional font (e.g., Arial, Times New Roman) unless otherwise instructed
Zero Formula Errors
- Deliver with zero formula errors (#REF!, #DIV/0!, #VALUE!, #N/A, #NAME?)
Preserve Existing Templates
- Study and match existing format, style, and conventions when modifying files
- Existing template conventions override these guidelines
Financial models
Color Coding Standards
Unless otherwise stated by the user or existing template:
- Blue text (0,0,255): Hardcoded inputs and scenario-adjustable numbers
- Black text (0,0,0): Formulas and calculations
- Green text (0,128,0): Links pulling from other worksheets within same workbook
- Red text (255,0,0): External links to other files
- Yellow background (255,255,0): Key assumptions needing attention
Number Formatting Standards
- Years: Format as text strings ("2024" not "2,024")
- Currency: Use $#,##0 format; specify units in headers ("Revenue ($mm)")
- Zeros: Display as "-" including percentages (e.g., "$#,##0;($#,##0);-")
- Percentages: Default to 0.0% format (one decimal)
- Multiples: Format as 0.0x for valuation multiples (EV/EBITDA, P/E)
- Negative numbers: Use parentheses (123) not minus -123
Formula Construction Rules
- Place all assumptions (growth rates, margins, multiples) in separate cells; use cell references instead of hardcoded values in formulas
- Example: Use
=B5*(1+$B$6) instead of =B5*1.05
- Verify all cell references, check for off-by-one errors in ranges
- Ensure consistent formulas across all projection periods
- Test with edge cases (zero values, negative numbers)
- Comment hardcoded values with source: "Source: [System], [Date], [Reference], [URL if applicable]"
XLSX creation, editing, and analysis
Use Formulas, Not Hardcoded Values
Use Excel formulas instead of calculating values in Python and hardcoding them — this keeps the spreadsheet dynamic and updateable.
❌ Wrong — hardcoded
total = df['Sales'].sum()
sheet['B10'] = total # Hardcodes 5000
✅ Correct — formula
sheet['B10'] = '=SUM(B2:B9)'
sheet['C5'] = '=(C4-C2)/C2'
sheet['D20'] = '=AVERAGE(D2:D19)'
This applies to all calculations — totals, percentages, ratios, differences.
Common Workflow
- Choose tool: pandas for data analysis, openpyxl for formulas/formatting
- Create/Load: Create new workbook or load existing file
- Modify: Add/edit data, formulas, and formatting
- Save: Write to file
- Recalculate formulas (when using formulas):
python scripts/recalc.py output.xlsx
- Verify and fix errors:
- The script returns JSON with error details
- If
status is errors_found, check error_summary for specific error types and locations
- Fix identified errors and recalculate again
LibreOffice is available for recalculation via scripts/recalc.py. The script auto-configures LibreOffice on first run.
Creating new Excel files
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment
wb = Workbook()
sheet = wb.active
sheet['A1'] = 'Hello'
sheet.append(['Row', 'of', 'data'])
sheet['B2'] = '=SUM(A1:A10)'
sheet['A1'].font = Font(bold=True, color='FF0000')
sheet['A1'].fill = PatternFill('solid', start_color='FFFF00')
sheet.column_dimensions['A'].width = 20
wb.save('output.xlsx')
Editing existing Excel files
from openpyxl import load_workbook
wb = load_workbook('existing.xlsx')
sheet = wb.active # or wb['SheetName']
sheet['A1'] = 'New Value'
sheet.insert_rows(2)
new_sheet = wb.create_sheet('NewSheet')
wb.save('modified.xlsx')
Recalculating formulas
python scripts/recalc.py <excel_file> [timeout_seconds]
The script:
- Recalculates all formulas in all sheets
- Scans all cells for Excel errors (#REF!, #DIV/0!, etc.)
- Returns JSON with detailed error locations and counts
Formula Verification Checklist
Interpreting recalc.py Output
{
"status": "success",
"total_errors": 0,
"total_formulas": 42,
"error_summary": {}
}
Library Selection
- pandas: Data analysis, bulk operations, simple data export
- openpyxl: Complex formatting, formulas, Excel-specific features
openpyxl tips
- Cell indices are 1-based (row=1, column=1 = A1)
- Use
data_only=True to read calculated values — but saving afterward replaces formulas with values permanently
- For large files: use
read_only=True or write_only=True
pandas tips
- Specify data types to avoid inference issues:
pd.read_excel('file.xlsx', dtype={'id': str})
- For large files:
pd.read_excel('file.xlsx', usecols=['A', 'C', 'E'])
- Handle dates:
pd.read_excel('file.xlsx', parse_dates=['date_column'])
1---2name: xlsx-original3description: Use this skill any time a spreadsheet file is the primary input or output (.xlsx, .xlsm, .csv, .tsv). This includes: creating, reading, editing, analyzing, or formatting spreadsheets; cleaning messy tabular data; converting between formats; and data visualization with charts. Also use for pandas-based data analysis when the deliverable is a spreadsheet. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration.4license: Proprietary. LICENSE.txt has complete terms5---67# Requirements for Outputs89## All Excel files1011### Professional Font12- Use a consistent, professional font (e.g., Arial, Times New Roman) unless otherwise instructed1314### Zero Formula Errors15- Deliver with zero formula errors (#REF!, #DIV/0!, #VALUE!, #N/A, #NAME?)1617### Preserve Existing Templates18- Study and match existing format, style, and conventions when modifying files19- Existing template conventions override these guidelines2021## Financial models2223### Color Coding Standards24Unless otherwise stated by the user or existing template:2526- **Blue text (0,0,255)**: Hardcoded inputs and scenario-adjustable numbers27- **Black text (0,0,0)**: Formulas and calculations28- **Green text (0,128,0)**: Links pulling from other worksheets within same workbook29- **Red text (255,0,0)**: External links to other files30- **Yellow background (255,255,0)**: Key assumptions needing attention3132### Number Formatting Standards3334- **Years**: Format as text strings ("2024" not "2,024")35- **Currency**: Use $#,##0 format; specify units in headers ("Revenue ($mm)")36- **Zeros**: Display as "-" including percentages (e.g., "$#,##0;($#,##0);-")37- **Percentages**: Default to 0.0% format (one decimal)38- **Multiples**: Format as 0.0x for valuation multiples (EV/EBITDA, P/E)39- **Negative numbers**: Use parentheses (123) not minus -1234041### Formula Construction Rules4243- Place all assumptions (growth rates, margins, multiples) in separate cells; use cell references instead of hardcoded values in formulas44 - Example: Use `=B5*(1+$B$6)` instead of `=B5*1.05`45- Verify all cell references, check for off-by-one errors in ranges46- Ensure consistent formulas across all projection periods47- Test with edge cases (zero values, negative numbers)48- Comment hardcoded values with source: "Source: [System], [Date], [Reference], [URL if applicable]"4950# XLSX creation, editing, and analysis5152## Use Formulas, Not Hardcoded Values5354Use Excel formulas instead of calculating values in Python and hardcoding them — this keeps the spreadsheet dynamic and updateable.5556### ❌ Wrong — hardcoded57```python58total = df['Sales'].sum()59sheet['B10'] = total # Hardcodes 500060```6162### ✅ Correct — formula63```python64sheet['B10'] = '=SUM(B2:B9)'65sheet['C5'] = '=(C4-C2)/C2'66sheet['D20'] = '=AVERAGE(D2:D19)'67```6869This applies to all calculations — totals, percentages, ratios, differences.7071## Common Workflow72731. **Choose tool**: pandas for data analysis, openpyxl for formulas/formatting742. **Create/Load**: Create new workbook or load existing file753. **Modify**: Add/edit data, formulas, and formatting764. **Save**: Write to file775. **Recalculate formulas** (when using formulas): `python scripts/recalc.py output.xlsx`786. **Verify and fix errors**:79 - The script returns JSON with error details80 - If `status` is `errors_found`, check `error_summary` for specific error types and locations81 - Fix identified errors and recalculate again8283**LibreOffice** is available for recalculation via `scripts/recalc.py`. The script auto-configures LibreOffice on first run.8485### Creating new Excel files8687```python88from openpyxl import Workbook89from openpyxl.styles import Font, PatternFill, Alignment9091wb = Workbook()92sheet = wb.active93sheet['A1'] = 'Hello'94sheet.append(['Row', 'of', 'data'])95sheet['B2'] = '=SUM(A1:A10)'96sheet['A1'].font = Font(bold=True, color='FF0000')97sheet['A1'].fill = PatternFill('solid', start_color='FFFF00')98sheet.column_dimensions['A'].width = 2099wb.save('output.xlsx')100```101102### Editing existing Excel files103104```python105from openpyxl import load_workbook106107wb = load_workbook('existing.xlsx')108sheet = wb.active # or wb['SheetName']109sheet['A1'] = 'New Value'110sheet.insert_rows(2)111new_sheet = wb.create_sheet('NewSheet')112wb.save('modified.xlsx')113```114115## Recalculating formulas116117```bash118python scripts/recalc.py <excel_file> [timeout_seconds]119```120121The script:122- Recalculates all formulas in all sheets123- Scans all cells for Excel errors (#REF!, #DIV/0!, etc.)124- Returns JSON with detailed error locations and counts125126## Formula Verification Checklist127128- [ ] Test 2-3 sample references before building full model129- [ ] Confirm column mapping (e.g., column 64 = BL, not BK)130- [ ] Account for row offset (DataFrame row 5 = Excel row 6)131- [ ] Handle NaN with `pd.notna()`132- [ ] Check denominators before `/` in formulas133- [ ] Verify cross-sheet references use correct format (Sheet1!A1)134- [ ] Start small: test formulas on 2-3 cells before applying broadly135136### Interpreting recalc.py Output137```json138{139 "status": "success",140 "total_errors": 0,141 "total_formulas": 42,142 "error_summary": {}143}144```145146## Library Selection147148- **pandas**: Data analysis, bulk operations, simple data export149- **openpyxl**: Complex formatting, formulas, Excel-specific features150151### openpyxl tips152- Cell indices are 1-based (row=1, column=1 = A1)153- Use `data_only=True` to read calculated values — but saving afterward replaces formulas with values permanently154- For large files: use `read_only=True` or `write_only=True`155156### pandas tips157- Specify data types to avoid inference issues: `pd.read_excel('file.xlsx', dtype={'id': str})`158- For large files: `pd.read_excel('file.xlsx', usecols=['A', 'C', 'E'])`159- Handle dates: `pd.read_excel('file.xlsx', parse_dates=['date_column'])`