Requirements for Outputs
All Excel files
Professional Font
Use a consistent, professional font (e.g., Arial, Times New Roman) for all deliverables unless otherwise instructed.
Zero Formula Errors
Every Excel model MUST be delivered with ZERO formula errors (#REF!, #DIV/0!, #VALUE!, #N/A, #NAME?).
Preserve Existing Templates
Study and EXACTLY match existing format, style, and conventions when modifying files. Never impose standardized formatting on files with established patterns.
Financial models
Color Coding Standards
Industry-Standard Color Conventions
- Blue text (RGB: 0,0,255): Hardcoded inputs and numbers users will change for scenarios
- Black text (RGB: 0,0,0): ALL formulas and calculations
- Green text (RGB: 0,128,0): Links pulling from other worksheets within same workbook
- Red text (RGB: 255,0,0): External links to other files
- Yellow background (RGB: 255,255,0): Key assumptions needing attention
Number Formatting Standards
- Years: Format as text strings (e.g., "2024" not "2,024")
- Currency: Use $#,##0 format; ALWAYS specify units in headers ("Revenue ($mm)")
- Zeros: Use number formatting to make all zeros "-"
- Percentages: Default to 0.0% format (one decimal)
- Multiples: Format as 0.0x for valuation multiples
- Negative numbers: Use parentheses (123) not minus -123
XLSX creation, editing, and analysis
CRITICAL: Use Formulas, Not Hardcoded Values
Always use Excel formulas instead of calculating values in Python and hardcoding them.
# ❌ WRONG - Hardcoding Calculated Values
total = df['Sales'].sum()
sheet['B10'] = total # Hardcodes 5000
# ✅ CORRECT - Using Excel Formulas
sheet['B10'] = '=SUM(B2:B9)'
sheet['C5'] = '=(C4-C2)/C2'
sheet['D20'] = '=AVERAGE(D2:D19)'
Reading and analyzing data
import pandas as pd
# Read Excel
df = pd.read_excel('file.xlsx')
all_sheets = pd.read_excel('file.xlsx', sheet_name=None) # All sheets as dict
# Analyze
df.head()
df.info()
df.describe()
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 (MANDATORY IF USING FORMULAS): Use LibreOffice macro or recalculation script
- Verify and fix any errors: Check for #REF!, #DIV/0!, #VALUE!, #NAME?
Creating new Excel files
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment
wb = Workbook()
sheet = wb.active
# Add data
sheet['A1'] = 'Hello'
sheet['B2'] = '=SUM(A1:A10)'
# Formatting
sheet['A1'].font = Font(bold=True, color='FF0000')
sheet['A1'].fill = PatternFill('solid', start_color='FFFF00')
sheet['A1'].alignment = Alignment(horizontal='center')
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
# Modify cells
sheet['A1'] = 'New Value'
sheet.insert_rows(2)
sheet.delete_cols(3)
wb.save('modified.xlsx')
Formula Verification Checklist
Best Practices
- pandas: Best for data analysis, bulk operations, and simple data export
- openpyxl: Best for complex formatting, formulas, and Excel-specific features
- Use
data_only=True to read calculated values - but Warning: saving with this flag permanently loses formulas
- Write minimal, concise Python code without unnecessary comments
1---2name: xlsx3description: Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path. Also trigger for cleaning or restructuring messy tabular data files into proper spreadsheets.4---56# Requirements for Outputs78## All Excel files910### Professional Font11Use a consistent, professional font (e.g., Arial, Times New Roman) for all deliverables unless otherwise instructed.1213### Zero Formula Errors14Every Excel model MUST be delivered with ZERO formula errors (#REF!, #DIV/0!, #VALUE!, #N/A, #NAME?).1516### Preserve Existing Templates17Study and EXACTLY match existing format, style, and conventions when modifying files. Never impose standardized formatting on files with established patterns.1819## Financial models2021### Color Coding Standards2223#### Industry-Standard Color Conventions24- **Blue text (RGB: 0,0,255)**: Hardcoded inputs and numbers users will change for scenarios25- **Black text (RGB: 0,0,0)**: ALL formulas and calculations26- **Green text (RGB: 0,128,0)**: Links pulling from other worksheets within same workbook27- **Red text (RGB: 255,0,0)**: External links to other files28- **Yellow background (RGB: 255,255,0)**: Key assumptions needing attention2930### Number Formatting Standards31- **Years**: Format as text strings (e.g., "2024" not "2,024")32- **Currency**: Use $#,##0 format; ALWAYS specify units in headers ("Revenue ($mm)")33- **Zeros**: Use number formatting to make all zeros "-"34- **Percentages**: Default to 0.0% format (one decimal)35- **Multiples**: Format as 0.0x for valuation multiples36- **Negative numbers**: Use parentheses (123) not minus -1233738---3940# XLSX creation, editing, and analysis4142## CRITICAL: Use Formulas, Not Hardcoded Values4344**Always use Excel formulas instead of calculating values in Python and hardcoding them.**4546```python47# ❌ WRONG - Hardcoding Calculated Values48total = df['Sales'].sum()49sheet['B10'] = total # Hardcodes 50005051# ✅ CORRECT - Using Excel Formulas52sheet['B10'] = '=SUM(B2:B9)'53sheet['C5'] = '=(C4-C2)/C2'54sheet['D20'] = '=AVERAGE(D2:D19)'55```5657## Reading and analyzing data5859```python60import pandas as pd6162# Read Excel63df = pd.read_excel('file.xlsx')64all_sheets = pd.read_excel('file.xlsx', sheet_name=None) # All sheets as dict6566# Analyze67df.head()68df.info()69df.describe()70```7172## Common Workflow73741. **Choose tool**: pandas for data analysis, openpyxl for formulas/formatting752. **Create/Load**: Create new workbook or load existing file763. **Modify**: Add/edit data, formulas, and formatting774. **Save**: Write to file785. **Recalculate formulas (MANDATORY IF USING FORMULAS)**: Use LibreOffice macro or recalculation script796. **Verify and fix any errors**: Check for #REF!, #DIV/0!, #VALUE!, #NAME?8081## Creating new Excel files8283```python84from openpyxl import Workbook85from openpyxl.styles import Font, PatternFill, Alignment8687wb = Workbook()88sheet = wb.active8990# Add data91sheet['A1'] = 'Hello'92sheet['B2'] = '=SUM(A1:A10)'9394# Formatting95sheet['A1'].font = Font(bold=True, color='FF0000')96sheet['A1'].fill = PatternFill('solid', start_color='FFFF00')97sheet['A1'].alignment = Alignment(horizontal='center')98sheet.column_dimensions['A'].width = 2099100wb.save('output.xlsx')101```102103## Editing existing Excel files104105```python106from openpyxl import load_workbook107108wb = load_workbook('existing.xlsx')109sheet = wb.active110111# Modify cells112sheet['A1'] = 'New Value'113sheet.insert_rows(2)114sheet.delete_cols(3)115116wb.save('modified.xlsx')117```118119## Formula Verification Checklist120121- [ ] **Test 2-3 sample references**: Verify they pull correct values before building full model122- [ ] **Column mapping**: Confirm Excel columns match expectations123- [ ] **Row offset**: Remember Excel rows are 1-indexed (DataFrame row 5 = Excel row 6)124- [ ] **NaN handling**: Check for null values with `pd.notna()`125- [ ] **Division by zero**: Check denominators before using `/` in formulas (#DIV/0!)126- [ ] **Wrong references**: Verify all cell references point to intended cells (#REF!)127- [ ] **Cross-sheet references**: Use correct format (Sheet1!A1) for linking sheets128129## Best Practices130131- **pandas**: Best for data analysis, bulk operations, and simple data export132- **openpyxl**: Best for complex formatting, formulas, and Excel-specific features133- Use `data_only=True` to read calculated values - but **Warning**: saving with this flag permanently loses formulas134- Write minimal, concise Python code without unnecessary comments