The `xlsx` Claude Code Skill: Generate Excel Spreadsheets with AI

Spreadsheets are the lingua franca of business data. Regardless of what your backend stores things in, there’s a good chance the people who need to see it want an Excel file. And regardless of how clean your data pipeline is, there’s a good chance you’re occasionally receiving data as an .xlsx and need to process it programmatically. The xlsx Claude Code skill handles both directions โ€” generating Excel files from data, and reading and transforming data from existing spreadsheets.

The Python ecosystem has three main contenders for spreadsheet work: openpyxl, xlsxwriter, and pandas with xlsxwriter as a writer engine. Each is better suited to different tasks, and choosing the wrong one leads to either capability gaps or unnecessary complexity. The skill encodes which tool to use when, and the correct patterns for each.


What the xlsx Skill Covers

Writing formatted spreadsheets. Creating .xlsx files with proper formatting โ€” cell styles, column widths, frozen rows, number formats, conditional formatting, merged cells, and borders. The skill covers xlsxwriter for write-only generation (faster, more formatting options) and openpyxl when you need to modify existing files.

Reading and transforming existing spreadsheets. Using openpyxl or pandas to read .xlsx files, handle merged cells correctly, skip header rows, and process multi-sheet workbooks. The skill covers the edge cases: cells that look numeric but are stored as strings, dates that Excel represents as serial numbers, and the correct way to handle None vs empty string in cell values.

Charts and pivot tables. Inserting charts from data ranges using xlsxwriter’s chart API, and generating pivot-table-like summaries using pandas groupby before writing. The skill covers the difference between these approaches and when to use each.

Data validation and protection. Adding dropdown validation to cells, protecting sheets with a password, and locking specific cell ranges โ€” common requirements when producing templates for non-technical users to fill in.


Example Workflow: Monthly Financial Report

A typical automation task: generating a formatted financial report spreadsheet from data exported from your accounting system.

Generate a monthly financial report from transactions.csv.
The spreadsheet should have:
- A Summary sheet with income, expenses, and net by category
- A Transactions sheet with all individual transactions
- Column headers in bold with a blue background
- Currency formatting on all monetary columns
- Totals row at the bottom of each sheet
- Freeze the header row on both sheets

Save to output/financial-report-may-2026.xlsx

The xlsx skill tells Claude to use xlsxwriter for this (write-only, better formatting API), the correct approach for defining cell formats once and reusing them (critical for performance on large sheets), and how to freeze rows and set column widths correctly. The result opens cleanly in Excel with proper formatting intact.


The Read vs Write Tool Split

The most important thing the skill encodes is the read/write split:

xlsxwriter is write-only. You can’t use it to open and modify an existing file. It’s the right choice when generating a new spreadsheet from scratch โ€” it’s faster than openpyxl and has a richer formatting API.

openpyxl can read and write. It’s the right choice when modifying an existing file โ€” updating cells, adding sheets to a template, or making targeted changes. It’s slower than xlsxwriter for large write operations.

pandas is the right layer when your data transformation is complex โ€” filtering, grouping, aggregating โ€” before writing the result out with either engine as the backend. The skill covers the correct ExcelWriter pattern for multi-sheet output.


Further Reading


Spreadsheet generation is one of the highest-leverage automation tasks in most organisations โ€” the difference between a manual weekly export and a scheduled script that produces a formatted, correctly structured file every Monday morning. The xlsx skill gives Claude the specific knowledge to write that script correctly from the first attempt, with the right tool, the right formatting patterns, and output that looks like a human made it.


Leave a Reply