build-spreadsheet
Skill9 starsChanged 5 months agoApache-2.0View on GitHub
Creates and edits XLSX workbooks with formulas, multi-sheet references, cell formatting, conditional formatting, pivot-style summaries, and native Excel charts.
- Installs packages
In this repository147 other files it gives its agents.
- second-brain/AGENTS.mdAGENTS.md
- second-brain/CLAUDE.mdCLAUDE.md
- agent-tool-mcp-builderSkill
- api-design-reviewSkill
- async-concurrency-correctnessSkill
- audit-accessibility-wcagSkill
- audit-license-complianceSkill
- audit-technical-seoSkill
- auth-jwt-sessionSkill
- author-codemodSkill
- brainstorm-designSkill
- build-audit-loggingSkill
- build-cdc-streaming-pipelineSkill
- build-cli-toolSkill
- build-data-tableSkill
- build-etl-pipelineSkill
- build-form-validationSkill
- build-native-mobile-uiSkill
- build-office-docsSkill
- build-offline-first-syncSkill
- build-react-componentSkill
- build-realtime-channelSkill
- build-vector-searchSkill
- caching-strategySkill
- cicd-pipeline-authorSkill
- cloud-cost-optimizeSkill
- code-commentsSkill
- code-reviewSkill
- compose-local-dev-stackSkill
- configure-bundler-buildSkill
- configure-dns-tlsSkill
- configure-reverse-proxy-lbSkill
- configure-security-headers-cspSkill
- contract-testingSkill
- datetime-timezone-correctnessSkill
- db-migration-safetySkill
- debug-ci-pipeline-failureSkill
- debug-flaky-testsSkill
- debug-frontend-browserSkill
- debug-root-causeSkill
- defend-llm-prompt-injectionSkill
- deliver-webhooksSkill
- dependency-upgradeSkill
- deploy-releaseSkill
- design-api-paginationSkill
- design-authorization-modelSkill
- design-backup-dr-recoverySkill
- design-event-sourcing-cqrsSkill
- design-multi-tenancySkill
- design-protobuf-grpc-serviceSkill
- design-relational-schemaSkill
- design-search-index-infraSkill
- design-state-machineSkill
- design-token-systemSkill
- diff-table-paritySkill
- distributed-locks-leasesSkill
- dockerfile-optimizeSkill
- encrypt-sensitive-dataSkill
- error-messageSkill
- estimate-workSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 9
Use this skill to produce a .xlsx artifact a human will open in Excel — a financial model, budget, tracker, report, or dashboard.
- Very specific: line 15
Default engine: openpyxl (read + write + formatting + native charts in one library).
- Distinctive: line 96
After saving, reopen and assert structure programmatically — never assume the write succeeded:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
When to Use
Use this skill to produce a .xlsx artifact a human will open in Excel — a financial model, budget, tracker, report, or dashboard. The deliverable is a live workbook: formulas recalculate, charts re-render, sheets cross-reference.
Reach for it when the request includes any of: "add a column that sums/looks-up", "format these cells", "highlight values over X", "build a summary sheet that pulls from the detail tabs", "make a chart", "turn this CSV into a real Excel model".
Not this skill — if the goal is to analyze data and report numbers back in chat (use pandas/data-wrangle). The line: data-wrangle answers a question, build-spreadsheet hands over a file.
Default engine: openpyxl (read + write + formatting + native charts in one library). Only switch to xlsxwriter for write-only generation of very large files (>50k rows) where speed matters — it is faster but cannot read or edit existing files.
Steps
- Install + import.
pip install openpyxlif missing. Then:
New file →from openpyxl import Workbook, load_workbook from openpyxl.styles import Font, PatternFill, Alignment, Border, Side from openpyxl.formatting.rule import ColorScaleRule, CellIsRule, FormulaRule from openpyxl.chart import BarChart, LineChart, PieChart, ScatterChart, Reference, Series from openpyxl.utils import get_column_letterwb = Workbook(). Editing an existing file →wb = load_workbook("in.xlsx")(adddata_only=Falseto keep formulas as formulas, not last-cached values). - Lay out sheets and headers.
ws = wb.active; ws.title = "Detail"; add more withwb.create_sheet("Summary"). Write headers, then write typed cell values — pass realint/float/datetime, not strings, or Excel treats numbers as text and SUM returns 0. Setcell.number_format = "yyyy-mm-dd"for dates. - Write formulas as strings, never precompute. Store the formula so Excel computes it:
A leadingws["D2"] = "=B2*C2" ws["E2"] = "=SUM(D2:D100)" ws["F2"] = '=VLOOKUP(A2,Detail!$A$2:$C$100,3,FALSE)'=is what makes it a formula. openpyxl does not evaluate it — the cell has no value until Excel/LibreOffice opens and recalcs the file. - Cross-sheet refs and named ranges. Reference another sheet with
SheetName!A1; quote sheet names containing spaces:'Q1 Detail'!A1. For reusable ranges:from openpyxl.workbook.defined_name import DefinedName wb.defined_names.add(DefinedName("tax_rate", attr_text="Assumptions!$B$1")) ws["C2"] = "=B2*tax_rate" - Formatting. Apply per cell (styles do not cascade from columns/rows):
ws["A1"].font = Font(bold=True, color="FFFFFF") ws["A1"].fill = PatternFill("solid", fgColor="305496") ws["B2"].number_format = '#,##0.00' # or '$#,##0', '0.0%', '#,##0;[Red](#,##0)' ws.column_dimensions["A"].width = 22 ws.freeze_panes = "A2" # lock header row - Conditional formatting is bound to a range and re-evaluates live in Excel:
ws.conditional_formatting.add("D2:D100", ColorScaleRule(start_type="min", start_color="F8696B", end_type="max", end_color="63BE7B")) ws.conditional_formatting.add("E2:E100", CellIsRule(operator="greaterThan", formula=["1000"], fill=PatternFill("solid", fgColor="FFC7CE"))) - Pivot-style summary — don't try to write a real PivotTable (openpyxl support is fragile). Instead build a summary sheet of unique keys +
SUMIF/COUNTIF/AVERAGEIFagainst the detail sheet, so totals stay live:ws_sum["B2"] = '=SUMIF(Detail!$A:$A,A2,Detail!$D:$D)' - Native charts bound to
Referenceranges (these recalc/redraw in Excel, unlike pasted images):
Swapchart = BarChart(); chart.title = "Sales by Region"; chart.type = "col" data = Reference(ws, min_col=2, min_row=1, max_col=2, max_row=10) # include header row cats = Reference(ws, min_col=1, min_row=2, max_row=10) chart.add_data(data, titles_from_data=True) chart.set_categories(cats) ws.add_chart(chart, "H2") # anchor cellBarChart→LineChart/PieChart/ScatterChartas needed. Scatter needsSeries(yvalues, xvalues)explicitly. - Save with
wb.save("out.xlsx"). Pick a clear, descriptive filename.
Common Errors
- Formula shows as text / SUM = 0. Either the string lacks a leading
=, or the summed cells hold strings not numbers. Write numeric values as realint/float. Also: a cell can hold a formula or a literal value, not both — openpyxl never fills in the computed result, so the file looks "empty" until opened and recalced. - Reading back gives
Nonefor formula cells.load_workbook(data_only=True)returns the last cached value Excel saved. A file written purely by openpyxl was never opened by Excel, so there is no cache →None. Usedata_only=Falseto read the formula string; open in Excel once and save if you need cached values. - Styles/charts vanish after editing an existing file.
load_workbookdrops what it can't model — VBA macros (unlesskeep_vba=True), some chart types, and many embedded PivotTables/images are lost on re-save. Verify after round-trip; for macro files keep.xlsm+keep_vba=True. - Style applied to a whole column doesn't show. openpyxl styles are per-cell; setting
column_dimensions[...].fontonly affects new cells, not existing ones. Loop the actual cells. - A
Font/Fill/Borderobject shared across cells can raiseStyleProxy/copy errors — create a fresh style object (orcopy()) per cell instead of reusing one instance. - Sheet name with spaces in a formula not quoted →
#REF!. Wrap in single quotes:'My Sheet'!A1. - Huge files blow memory. For tens of thousands of rows, write with
Workbook(write_only=True)+ws.append(row_list)(no random cell access, no formatting mid-stream), or usexlsxwriter. - Color hex is
RRGGBB(orAARRGGBB), no#."#FF0000"fails silently or errors.
Verify
After saving, reopen and assert structure programmatically — never assume the write succeeded:
chk = load_workbook("out.xlsx")
assert {"Detail", "Summary"} <= set(chk.sheetnames)
assert chk["Detail"]["D2"].value == "=B2*C2" # formula stored as string
assert chk["Detail"]["D2"].data_type == "f" # 'f' = formula
assert len(chk["Detail"]._charts) >= 1 # chart survived saveThen do a real recalc check: open the file once in Excel or headless LibreOffice (libreoffice --headless --convert-to xlsx out.xlsx) and confirm formula cells show numbers, not 0/#REF!/text. If totals are 0, the inputs were strings — go back to step 2.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

