Excel Spreadsheets Skill
Acknowledgement: Shared by Peter Bamuhigire, techguypeter.com, +256 784 464178.
Required Inputs
| Input |
Required |
Use |
| Decision, audience, and deliverable |
yes |
Bound the business outcome |
| Source evidence, constraints, and owner |
yes |
Ground recommendations and accountability |
| Approved budget, customer data, or production artefacts |
conditional |
Support high-impact execution |
Capability and permission contract
Default to read-only analysis and drafting. Do not publish, send, price, promise, alter customer records, commit budget, or modify production artefacts without explicit authority and a named approver. Minimise confidential data, preserve provenance, and keep reversible copies.
Degraded mode
If evidence, stakeholder decisions, specialist tooling, or authoritative commercial data are unavailable, deliver a labelled draft, checklist, or decision memo. State what was not verified and do not claim approval, publication, financial accuracy, or customer acceptance.
Decision rules
| Condition |
Action |
Stop condition |
| Output creates a commercial, customer, or delivery commitment |
Obtain named approval before release |
Authority or terms are unclear |
| Evidence supports a reversible draft |
Produce it with assumptions and owner |
Required evidence conflicts |
| Tooling or data is incomplete |
Specify validation |
A final executable artefact is expected |
Domain Anti-Patterns
- Inventing customer evidence, prices, benchmarks, or approvals. Fix: cite the source or mark the gap.
- Publishing or sending a draft without authority. Fix: retain draft status and name the approver.
- Hiding assumptions inside polished prose. Fix: expose them beside each affected decision.
- Polishing presentation while the decision remains unclear. Fix: resolve audience, owner, and acceptance criteria.
- Treating unavailable tooling as passed validation. Fix: record the unassessed check.
Use When
- Generate world-class, professionally designed Microsoft Excel spreadsheets and handle all Excel/spreadsheet workflows. Use when: generating .xlsx files from apps or scripts (openpyxl, xlsxwriter, PhpSpreadsheet, pandas), importing or parsing...
Evidence Produced
| Category |
Artifact |
Format |
Example |
| Release evidence |
Generated Excel workbook |
Branded .xlsx artefact compliant with the excel-spreadsheets design standard |
docs/output/dashboard-2026-04-16.xlsx |
References
- Use the
references/ directory for deep detail after reading the core workflow below.
Excel done right looks like a financial analyst and a graphic designer collaborated on it. Done wrong, it's a wall of unformatted data nobody trusts. This skill covers both the code that generates Excel files and the design standards that make them world-class.
Reference files (read when needed):
references/design-standards.md — layout, colour palettes, typography, table structure, conditional formatting, print setup
references/formulas-functions.md — XLOOKUP, dynamic arrays, LET, LAMBDA, SUMIFS, MAXIFS/MINIFS, essential formula patterns
references/programmatic-generation.md — openpyxl, xlsxwriter, PhpSpreadsheet, pandas — code patterns for generating professional Excel from apps
references/charts-pivot.md — chart types, professional chart formatting, PivotTables, slicers, dashboards
references/financial-modeling.md — PMT, PV, FV, NPV, IRR; Goal Seek, Data Tables, Scenario Manager, Solver; modeling golden rules; formula debugging
references/finance-accounting-workbooks.md — bookkeeping ledgers, trial balance, AR/AP aging, bank reconciliation, fixed assets, budgets, cost accounting, statement checks, and finance dashboards
references/python-automation.md — Excel–Python–Excel workflow, advanced read_excel(), 6-step export, pivot_table/merge/crosstab, email automation, =PY() function, xlwings
references/vba-macros.md — recording/running macros, VBA golden rules, common patterns, keyboard shortcuts reference
references/quality-checklist.md — pre-delivery checklist
Sources: Microsoft Excel 365 Bible (Walkenbach/Alexander); Microsoft Excel Bible 2026; Ultimate Excel Formula & Function Reference Guide; Excel 2025 All-in-One; Excel 2019 Advanced Topics (George); Advanced Excel for Productivity (Urban); Automate Excel with Python (Wengler, 2026); Python in Excel Advanced (Van Der Post)
The Standard
Every spreadsheet produced must pass: a data analyst and a designer would both be satisfied. Specifically:
- Data lives in a properly structured Excel Table — never raw ranges
- Every number has an intentional format (currency, %, dates — never General)
- Visual hierarchy is clear: header rows are distinct, data rows are readable
- Formulas are correct, efficient, and use structured references where possible
- The file opens correctly on any machine, in any regional locale
Core Architecture Rules
Rule 1 — Always use Excel Tables
Convert every data range to an Excel Table (Ctrl+T) immediately. Tables give you:
- Structured references:
=Table1[Amount] instead of =$C$2:$C$100
- Auto-expansion when new rows are added
- Built-in filter arrows
- Automatic banded rows
- Named reference for programmatic access
Programmatic: In openpyxl, xlsxwriter, and PhpSpreadsheet, always add a Table (ListObject) definition over data ranges. See references/programmatic-generation.md.
Rule 2 — One table per sheet, one topic per sheet
Never mix multiple unrelated datasets on one sheet. Use separate sheets with clear names. Sheet names: PascalCase or Title Case, max 20 characters, no spaces (use underscores if needed).
Rule 3 — Separate data from presentation
- Data sheets — raw data in Tables, no decorative formatting, no merged cells
- Report/Dashboard sheets — formulas pulling from data sheets, full formatting treatment
- Configuration sheets (hidden) — lookup lists, parameters, constants
Rule 4 — Never merge cells in data ranges
Merged cells break sorting, filtering, PivotTables, and programmatic reading. For visual centering of headers, use Center Across Selection instead (Format Cells → Alignment → Horizontal: Center Across Selection).
Excel Table Design
Read references/design-standards.md for full colour palettes and formatting specs.
Standard table anatomy:
Row 1: Sheet title / document header ← merged+centred, large font, brand colour
Row 2: Subtitle / date / filter info ← smaller, grey
Row 3: [blank spacer row]
Row 4: Table header row ← Excel Table header (bold, brand fill, white text)
Row 5+: Data rows ← banded, 11pt, left/right aligned by type
Last: Totals row ← bold, top border, SUM/AVERAGE via Table totals row
Column alignment rules:
- Text columns → left-aligned
- Number/currency columns → right-aligned
- Date columns → right-aligned or centred
- Status/category columns → centred
- Header row → match column alignment (not always centred)
Number Formats (critical — never leave as General)
| Data type |
Format code |
Example output |
| Currency (UGX/KES/TZS) |
#,##0 |
1,250,000 |
| Currency with decimals |
#,##0.00 |
1,250,000.00 |
| USD |
"$"#,##0.00 |
$1,250.00 |
| Percentage |
0.00% |
12.50% |
| Percentage (whole) |
0% |
13% |
| Date (display) |
DD MMM YYYY |
05 Apr 2026 |
| Date (ISO sort) |
YYYY-MM-DD |
2026-04-05 |
| Large numbers |
#,##0.0,,"M" |
1.3M |
| Negative red |
#,##0.00;[Red]-#,##0.00 |
-500.00 (red) |
| Integer |
#,##0 |
42,000 |
| Duration (hours) |
[h]:mm |
37:30 |
Custom format anatomy: positive;negative;zero;text
Essential Formulas
Read references/formulas-functions.md for full formula patterns. Core rules:
Use structured references in Tables:
=SUMIFS(Sales[Amount], Sales[Region], [@Region], Sales[Status], "Paid")
XLOOKUP over VLOOKUP always:
=XLOOKUP([@ID], Products[ID], Products[Price], "Not found", 0)
Dynamic arrays for reports:
=FILTER(Sales[#All], (Sales[Region]="East")*(Sales[Month]=B2))
=SORT(UNIQUE(Sales[Category]))
=SEQUENCE(12, 1, DATE(2026,1,1), 30)
The last example generates dates 30 days apart, not calendar-month dates.
For monthly schedules, use a calendar-aware formula and verify February,
month-end and year-boundary results in the target spreadsheet application.
LET for complex formulas (readability + performance):
=LET(
data, FILTER(Sales[Amount], Sales[Status]="Paid"),
avg, AVERAGE(data),
IF(avg>100000, "Above target", "Below target")
)
Data Validation
Every user-input column must have data validation. Never let free-form text corrupt a data column.
Dropdown from a Table column:
- Source:
=INDIRECT("Table1[Category]") or a named range
- Input message: "Select a category from the list"
- Error alert: Stop — "Invalid entry. Please select from the list."
Date range validation:
- Allow: Date, Between,
=TODAY()-365, =TODAY()+365
Whole number range:
- Allow: Whole number, Between, 0, 1000000
Conditional Formatting
Apply to entire Table columns, not fixed ranges (so it auto-expands with the Table).
Standard patterns:
- Heat map (numeric): 3-colour scale, low=white, mid=yellow, high=brand colour
- Above/below average: Green fill for above, red fill for below
- Status column: Formula-based —
=[@Status]="Paid" → green; =[@Status]="Overdue" → red
- Data bars: For ranking/comparison columns — no border, solid fill, brand colour
- Duplicate detection:
=COUNTIF(Table1[Email],[@Email])>1 → orange fill
Professional Finishing
Read references/design-standards.md → Professional Finishing section.
Freeze panes: Always freeze the header row (and optionally the first column for wide tables). View → Freeze Panes → Freeze Top Row.
Print setup (every sheet intended for printing):
- Page Layout → Page Setup:
- Orientation: Landscape for wide tables
- Scale to fit: 1 page wide, auto tall
- Print titles: Row 1 (and Table header row) to repeat on every page
- Margins: Narrow (0.64 cm) for data tables; Normal for reports
- Header: Document name left, date centre, page number right
- Footer: "Page &P of &N" centred, confidential notice if needed
Workbook hygiene:
- Delete all unused sheets (Sheet1, Sheet2, Sheet3)
- Name every sheet clearly
- Set the first sheet as the active sheet on open
- Remove all #REF!, #VALUE!, #NAME? errors before delivery
Programmatic Generation
Read references/programmatic-generation.md for full code patterns per language/library.
Library selection:
| Use case |
Library |
Language |
| Full formatting + charts |
openpyxl |
Python |
| Large data, max performance |
xlsxwriter |
Python |
| PHP apps |
PhpSpreadsheet |
PHP |
| Data analysis output |
pandas + openpyxl |
Python |
| Node.js apps |
exceljs |
JavaScript |
Non-negotiable programmatic rules:
- Always define a
Table (add_table / addTableStyleInfo) over data — never just write raw rows
- Always set column widths — auto-width from content, with min 8 and max 60 characters
- Always apply number formats to numeric columns — never leave as default
- Always freeze the header row
- Always set a tab colour per sheet for multi-sheet workbooks
- Always use a professional table style (TableStyleMedium2 or equivalent)
Import / Parsing Patterns
When reading Excel files in applications:
Always:
- Read with
header=0 (first row is headers) unless the file has multi-row headers
- Strip whitespace from string columns after reading
- Validate expected columns exist before processing — fail early with clear error messages
- Parse date columns explicitly (don't rely on auto-detection)
- Handle merged header cells by forward-filling merged values
Never:
- Assume column order — always reference by column name, not index
- Assume data starts at row 1 — check for title rows above the table
- Trust data types — validate and coerce explicitly
Python pattern:
import pandas as pd
df = pd.read_excel("file.xlsx", sheet_name="Sales", header=0)
df.columns = df.columns.str.strip() # remove whitespace from headers
df["Date"] = pd.to_datetime(df["Date"], dayfirst=True)
df["Amount"] = pd.to_numeric(df["Amount"], errors="coerce")
df = df.dropna(subset=["ID"]) # drop rows with no ID
Financial Functions Quick Reference
Read references/financial-modeling.md for full formulas, examples, and What-If tools. Read references/finance-accounting-workbooks.md when the workbook is a ledger, trial balance, aging report, reconciliation, financial model, budget, forecast, cost model, or finance dashboard.
| Function |
Use case |
Key rule |
=PMT(rate, nper, pv) |
Monthly loan/mortgage payment |
Rate and nper must match time unit (÷12 for monthly) |
=PV(rate, nper, pmt) |
Present value of an annuity |
Cash inflows = positive, outflows = negative |
=FV(rate, nper, pmt) |
Future value of savings/investment |
pmt is negative (cash going out) |
=NPV(rate, cashflows) |
Net present value |
Add period-0 investment separately outside NPV() |
=IRR(cashflows) |
Internal rate of return |
First value should be negative (initial outlay) |
What-If tools:
- Goal Seek — find the input that achieves a target output (Data → What-If Analysis → Goal Seek)
- Scenario Manager — store and compare named sets of input values (Base/Optimistic/Pessimistic)
- Data Tables — calculate output across a range of input values (1-variable or 2-variable)
- Solver — optimise across multiple variables with constraints (requires Solver add-in)
VBA Macros
Read references/vba-macros.md for full VBA patterns and keyboard shortcuts.
Record a macro: View → Macros → Record Macro (or status bar button bottom-left)
Run a macro: Alt+F8 or assigned shortcut key
Edit a macro: Alt+F11 opens the VBA editor
Critical shortcuts:
Ctrl+Arrow — jump to end of data range
F2 — edit mode with colour-coded cell references
F4 — toggle $A$1 → A$1 → $A1 → A1 (absolute/relative)
Ctrl+Shift+Enter — legacy array formula (prefer dynamic arrays)
Alt+H+O+I — auto-fit column width
Customisation Quick Reference
| What to change |
Where |
| Table colour palette |
references/design-standards.md → Colour Palettes |
| Formula patterns |
references/formulas-functions.md |
| openpyxl/xlsxwriter code |
references/programmatic-generation.md |
| Chart types and formatting |
references/charts-pivot.md |
| Financial functions & What-If |
references/financial-modeling.md |
| Finance/accounting workbooks |
references/finance-accounting-workbooks.md |
| Python automation & =PY() |
references/python-automation.md |
| VBA macros & keyboard shortcuts |
references/vba-macros.md |
| Pre-delivery checks |
references/quality-checklist.md |
Quality Standards
Workbook acceptance requires formula, source, error-state, protection, accessibility, and rendered-layout checks at the intended application boundary.
Outputs
| Artefact |
Consumer |
Acceptance condition |
| Validated workbook and QA note |
Analyst or operational owner |
Formulas recalculate, source ranges are traceable, error states are handled, and visual checks cover the intended spreadsheet application |
1---2name: excel-spreadsheets3description: Use when generating or validating professional Excel workbooks, formulas, imports, charts, formatting, macros, or spreadsheet deliverables.4metadata:5 portable: true6 compatible_with:7 - claude-code8 - codex9---1011# Excel Spreadsheets Skill12Acknowledgement: Shared by Peter Bamuhigire, techguypeter.com, +256 784 464178.131415## Required Inputs1617| Input | Required | Use |18|---|---|---|19| Decision, audience, and deliverable | yes | Bound the business outcome |20| Source evidence, constraints, and owner | yes | Ground recommendations and accountability |21| Approved budget, customer data, or production artefacts | conditional | Support high-impact execution |2223## Capability and permission contract2425Default to read-only analysis and drafting. Do not publish, send, price, promise, alter customer records, commit budget, or modify production artefacts without explicit authority and a named approver. Minimise confidential data, preserve provenance, and keep reversible copies.2627## Degraded mode2829If evidence, stakeholder decisions, specialist tooling, or authoritative commercial data are unavailable, deliver a labelled draft, checklist, or decision memo. State what was not verified and do not claim approval, publication, financial accuracy, or customer acceptance.3031## Decision rules3233| Condition | Action | Stop condition |34|---|---|---|35| Output creates a commercial, customer, or delivery commitment | Obtain named approval before release | Authority or terms are unclear |36| Evidence supports a reversible draft | Produce it with assumptions and owner | Required evidence conflicts |37| Tooling or data is incomplete | Specify validation | A final executable artefact is expected |3839## Domain Anti-Patterns4041- Inventing customer evidence, prices, benchmarks, or approvals. Fix: cite the source or mark the gap.42- Publishing or sending a draft without authority. Fix: retain draft status and name the approver.43- Hiding assumptions inside polished prose. Fix: expose them beside each affected decision.44- Polishing presentation while the decision remains unclear. Fix: resolve audience, owner, and acceptance criteria.45- Treating unavailable tooling as passed validation. Fix: record the unassessed check.464748<!-- dual-compat-start -->49## Use When5051- Generate world-class, professionally designed Microsoft Excel spreadsheets and handle all Excel/spreadsheet workflows. Use when: generating .xlsx files from apps or scripts (openpyxl, xlsxwriter, PhpSpreadsheet, pandas), importing or parsing...5253## Evidence Produced5455| Category | Artifact | Format | Example |56|----------|----------|--------|---------|57| Release evidence | Generated Excel workbook | Branded .xlsx artefact compliant with the excel-spreadsheets design standard | `docs/output/dashboard-2026-04-16.xlsx` |5859## References6061- Use the `references/` directory for deep detail after reading the core workflow below.62<!-- dual-compat-end -->63Excel done right looks like a financial analyst and a graphic designer collaborated on it. Done wrong, it's a wall of unformatted data nobody trusts. This skill covers both the code that generates Excel files and the design standards that make them world-class.6465**Reference files (read when needed):**66- `references/design-standards.md` — layout, colour palettes, typography, table structure, conditional formatting, print setup67- `references/formulas-functions.md` — XLOOKUP, dynamic arrays, LET, LAMBDA, SUMIFS, MAXIFS/MINIFS, essential formula patterns68- `references/programmatic-generation.md` — openpyxl, xlsxwriter, PhpSpreadsheet, pandas — code patterns for generating professional Excel from apps69- `references/charts-pivot.md` — chart types, professional chart formatting, PivotTables, slicers, dashboards70- `references/financial-modeling.md` — PMT, PV, FV, NPV, IRR; Goal Seek, Data Tables, Scenario Manager, Solver; modeling golden rules; formula debugging71- `references/finance-accounting-workbooks.md` — bookkeeping ledgers, trial balance, AR/AP aging, bank reconciliation, fixed assets, budgets, cost accounting, statement checks, and finance dashboards72- `references/python-automation.md` — Excel–Python–Excel workflow, advanced read_excel(), 6-step export, pivot_table/merge/crosstab, email automation, =PY() function, xlwings73- `references/vba-macros.md` — recording/running macros, VBA golden rules, common patterns, keyboard shortcuts reference74- `references/quality-checklist.md` — pre-delivery checklist7576*Sources: Microsoft Excel 365 Bible (Walkenbach/Alexander); Microsoft Excel Bible 2026; Ultimate Excel Formula & Function Reference Guide; Excel 2025 All-in-One; Excel 2019 Advanced Topics (George); Advanced Excel for Productivity (Urban); Automate Excel with Python (Wengler, 2026); Python in Excel Advanced (Van Der Post)*7778---7980## The Standard8182Every spreadsheet produced must pass: **a data analyst and a designer would both be satisfied.** Specifically:83841. Data lives in a properly structured **Excel Table** — never raw ranges852. Every number has an intentional format (currency, %, dates — never General)863. Visual hierarchy is clear: header rows are distinct, data rows are readable874. Formulas are correct, efficient, and use structured references where possible885. The file opens correctly on any machine, in any regional locale8990---9192## Core Architecture Rules9394### Rule 1 — Always use Excel Tables9596Convert every data range to an Excel Table (`Ctrl+T`) immediately. Tables give you:97- Structured references: `=Table1[Amount]` instead of `=$C$2:$C$100`98- Auto-expansion when new rows are added99- Built-in filter arrows100- Automatic banded rows101- Named reference for programmatic access102103**Programmatic:** In openpyxl, xlsxwriter, and PhpSpreadsheet, always add a `Table` (ListObject) definition over data ranges. See `references/programmatic-generation.md`.104105### Rule 2 — One table per sheet, one topic per sheet106107Never mix multiple unrelated datasets on one sheet. Use separate sheets with clear names. Sheet names: PascalCase or Title Case, max 20 characters, no spaces (use underscores if needed).108109### Rule 3 — Separate data from presentation110111- **Data sheets** — raw data in Tables, no decorative formatting, no merged cells112- **Report/Dashboard sheets** — formulas pulling from data sheets, full formatting treatment113- **Configuration sheets** (hidden) — lookup lists, parameters, constants114115### Rule 4 — Never merge cells in data ranges116117Merged cells break sorting, filtering, PivotTables, and programmatic reading. For visual centering of headers, use **Center Across Selection** instead (Format Cells → Alignment → Horizontal: Center Across Selection).118119---120121## Excel Table Design122123Read `references/design-standards.md` for full colour palettes and formatting specs.124125**Standard table anatomy:**126127```128Row 1: Sheet title / document header ← merged+centred, large font, brand colour129Row 2: Subtitle / date / filter info ← smaller, grey130Row 3: [blank spacer row]131Row 4: Table header row ← Excel Table header (bold, brand fill, white text)132Row 5+: Data rows ← banded, 11pt, left/right aligned by type133Last: Totals row ← bold, top border, SUM/AVERAGE via Table totals row134```135136**Column alignment rules:**137- Text columns → left-aligned138- Number/currency columns → right-aligned139- Date columns → right-aligned or centred140- Status/category columns → centred141- Header row → match column alignment (not always centred)142143---144145## Number Formats (critical — never leave as General)146147| Data type | Format code | Example output |148|---|---|---|149| Currency (UGX/KES/TZS) | `#,##0` | 1,250,000 |150| Currency with decimals | `#,##0.00` | 1,250,000.00 |151| USD | `"$"#,##0.00` | $1,250.00 |152| Percentage | `0.00%` | 12.50% |153| Percentage (whole) | `0%` | 13% |154| Date (display) | `DD MMM YYYY` | 05 Apr 2026 |155| Date (ISO sort) | `YYYY-MM-DD` | 2026-04-05 |156| Large numbers | `#,##0.0,,"M"` | 1.3M |157| Negative red | `#,##0.00;[Red]-#,##0.00` | -500.00 (red) |158| Integer | `#,##0` | 42,000 |159| Duration (hours) | `[h]:mm` | 37:30 |160161**Custom format anatomy:** `positive;negative;zero;text`162163---164165## Essential Formulas166167Read `references/formulas-functions.md` for full formula patterns. Core rules:168169**Use structured references in Tables:**170```excel171=SUMIFS(Sales[Amount], Sales[Region], [@Region], Sales[Status], "Paid")172```173174**XLOOKUP over VLOOKUP always:**175```excel176=XLOOKUP([@ID], Products[ID], Products[Price], "Not found", 0)177```178179**Dynamic arrays for reports:**180```excel181=FILTER(Sales[#All], (Sales[Region]="East")*(Sales[Month]=B2))182=SORT(UNIQUE(Sales[Category]))183=SEQUENCE(12, 1, DATE(2026,1,1), 30)184```185186The last example generates dates 30 days apart, not calendar-month dates.187For monthly schedules, use a calendar-aware formula and verify February,188month-end and year-boundary results in the target spreadsheet application.189190**LET for complex formulas (readability + performance):**191```excel192=LET(193 data, FILTER(Sales[Amount], Sales[Status]="Paid"),194 avg, AVERAGE(data),195 IF(avg>100000, "Above target", "Below target")196)197```198199---200201## Data Validation202203Every user-input column must have data validation. Never let free-form text corrupt a data column.204205**Dropdown from a Table column:**206- Source: `=INDIRECT("Table1[Category]")` or a named range207- Input message: "Select a category from the list"208- Error alert: Stop — "Invalid entry. Please select from the list."209210**Date range validation:**211- Allow: Date, Between, `=TODAY()-365`, `=TODAY()+365`212213**Whole number range:**214- Allow: Whole number, Between, 0, 1000000215216---217218## Conditional Formatting219220Apply to entire Table columns, not fixed ranges (so it auto-expands with the Table).221222**Standard patterns:**223- **Heat map (numeric):** 3-colour scale, low=white, mid=yellow, high=brand colour224- **Above/below average:** Green fill for above, red fill for below225- **Status column:** Formula-based — `=[@Status]="Paid"` → green; `=[@Status]="Overdue"` → red226- **Data bars:** For ranking/comparison columns — no border, solid fill, brand colour227- **Duplicate detection:** `=COUNTIF(Table1[Email],[@Email])>1` → orange fill228229---230231## Professional Finishing232233Read `references/design-standards.md` → Professional Finishing section.234235**Freeze panes:** Always freeze the header row (and optionally the first column for wide tables). View → Freeze Panes → Freeze Top Row.236237**Print setup (every sheet intended for printing):**238- Page Layout → Page Setup:239 - Orientation: Landscape for wide tables240 - Scale to fit: 1 page wide, auto tall241 - Print titles: Row 1 (and Table header row) to repeat on every page242 - Margins: Narrow (0.64 cm) for data tables; Normal for reports243 - Header: Document name left, date centre, page number right244 - Footer: "Page &P of &N" centred, confidential notice if needed245246**Workbook hygiene:**247- Delete all unused sheets (Sheet1, Sheet2, Sheet3)248- Name every sheet clearly249- Set the first sheet as the active sheet on open250- Remove all #REF!, #VALUE!, #NAME? errors before delivery251252---253254## Programmatic Generation255256Read `references/programmatic-generation.md` for full code patterns per language/library.257258**Library selection:**259260| Use case | Library | Language |261|---|---|---|262| Full formatting + charts | openpyxl | Python |263| Large data, max performance | xlsxwriter | Python |264| PHP apps | PhpSpreadsheet | PHP |265| Data analysis output | pandas + openpyxl | Python |266| Node.js apps | exceljs | JavaScript |267268**Non-negotiable programmatic rules:**2691. Always define a `Table` (add_table / addTableStyleInfo) over data — never just write raw rows2702. Always set column widths — auto-width from content, with min 8 and max 60 characters2713. Always apply number formats to numeric columns — never leave as default2724. Always freeze the header row2735. Always set a tab colour per sheet for multi-sheet workbooks2746. Always use a professional table style (TableStyleMedium2 or equivalent)275276---277278## Import / Parsing Patterns279280When reading Excel files in applications:281282**Always:**283- Read with `header=0` (first row is headers) unless the file has multi-row headers284- Strip whitespace from string columns after reading285- Validate expected columns exist before processing — fail early with clear error messages286- Parse date columns explicitly (don't rely on auto-detection)287- Handle merged header cells by forward-filling merged values288289**Never:**290- Assume column order — always reference by column name, not index291- Assume data starts at row 1 — check for title rows above the table292- Trust data types — validate and coerce explicitly293294**Python pattern:**295```python296import pandas as pd297298df = pd.read_excel("file.xlsx", sheet_name="Sales", header=0)299df.columns = df.columns.str.strip() # remove whitespace from headers300df["Date"] = pd.to_datetime(df["Date"], dayfirst=True)301df["Amount"] = pd.to_numeric(df["Amount"], errors="coerce")302df = df.dropna(subset=["ID"]) # drop rows with no ID303```304305---306307## Financial Functions Quick Reference308309Read `references/financial-modeling.md` for full formulas, examples, and What-If tools. Read `references/finance-accounting-workbooks.md` when the workbook is a ledger, trial balance, aging report, reconciliation, financial model, budget, forecast, cost model, or finance dashboard.310311| Function | Use case | Key rule |312|---|---|---|313| `=PMT(rate, nper, pv)` | Monthly loan/mortgage payment | Rate and nper must match time unit (÷12 for monthly) |314| `=PV(rate, nper, pmt)` | Present value of an annuity | Cash inflows = positive, outflows = negative |315| `=FV(rate, nper, pmt)` | Future value of savings/investment | pmt is negative (cash going out) |316| `=NPV(rate, cashflows)` | Net present value | Add period-0 investment separately outside NPV() |317| `=IRR(cashflows)` | Internal rate of return | First value should be negative (initial outlay) |318319**What-If tools:**320- **Goal Seek** — find the input that achieves a target output (Data → What-If Analysis → Goal Seek)321- **Scenario Manager** — store and compare named sets of input values (Base/Optimistic/Pessimistic)322- **Data Tables** — calculate output across a range of input values (1-variable or 2-variable)323- **Solver** — optimise across multiple variables with constraints (requires Solver add-in)324325---326327## VBA Macros328329Read `references/vba-macros.md` for full VBA patterns and keyboard shortcuts.330331**Record a macro:** View → Macros → Record Macro (or status bar button bottom-left)332**Run a macro:** `Alt+F8` or assigned shortcut key333**Edit a macro:** `Alt+F11` opens the VBA editor334335**Critical shortcuts:**336- `Ctrl+Arrow` — jump to end of data range337- `F2` — edit mode with colour-coded cell references338- `F4` — toggle `$A$1` → `A$1` → `$A1` → `A1` (absolute/relative)339- `Ctrl+Shift+Enter` — legacy array formula (prefer dynamic arrays)340- `Alt+H+O+I` — auto-fit column width341342---343344## Customisation Quick Reference345346| What to change | Where |347|---|---|348| Table colour palette | `references/design-standards.md` → Colour Palettes |349| Formula patterns | `references/formulas-functions.md` |350| openpyxl/xlsxwriter code | `references/programmatic-generation.md` |351| Chart types and formatting | `references/charts-pivot.md` |352| Financial functions & What-If | `references/financial-modeling.md` |353| Finance/accounting workbooks | `references/finance-accounting-workbooks.md` |354| Python automation & =PY() | `references/python-automation.md` |355| VBA macros & keyboard shortcuts | `references/vba-macros.md` |356| Pre-delivery checks | `references/quality-checklist.md` |357## Quality Standards358359Workbook acceptance requires formula, source, error-state, protection, accessibility, and rendered-layout checks at the intended application boundary.360361## Outputs362363| Artefact | Consumer | Acceptance condition |364|---|---|---|365| Validated workbook and QA note | Analyst or operational owner | Formulas recalculate, source ranges are traceable, error states are handled, and visual checks cover the intended spreadsheet application |