Can Claude Code work with my Excel files?
Ask Claude Code for an Excel workbook with live formulas, without touching your original file, and learn why those two conditions matter.
Free course. Your Maestro, an AI, .
Yes. When you work in Excel, you open the program and click cells, tabs and menus. Other AI tools, like Copilot or the Claude add-in for Excel, live inside that window and work on the workbook you have open. Claude Code reaches your data another way: from your Glossary word, it writes and runs Python code that reads your tables and builds .xlsx files right in your folder, without opening the Excel app.
That has a huge practical upside: it can read a big Glossary word or several workbooks already in your folder, join them, filter them and build you a new .xlsx file that you then open in your usual Excel. To do that work it uses Python Glossary word like Glossary word, which it uses to inspect and filter rows, and openpyxl, which it uses to write Excel sheets, cells and formulas.
For the workbook it hands you to be truly useful at work and safe to check, you need to ask for two conditions that you set in your instruction:
- Keep what it reads apart from what it writes (so it never touches your original file). A common mistake when starting out is asking the agent to "fix" or "clean up" your original file. If it overwrites your source file and makes a mistake filtering or deleting rows, you're left with nothing to compare against. Giving Claude Code only the access it needs for the task means separating reading from writing: it reads
planetas.csvwithout changing it and writes all its work to a new file,resumen.xlsx. That way your source file stays intact and you can always go back to it. - Make every number in the summary a live Excel formula. If Claude Code does the counts in Python and only writes the final numbers into the cells, the sheet looks identical at first glance, but it's dead: click the total or a percentage and you only see a fixed number, with no way to check which rows it counted. When you ask for formulas, the calculation stays visible inside Excel: you select the cell, look at the formula bar and see exactly which sheet and range it points to.
The request
In your exoplanetas folder, where you downloaded planetas.csv in the previous module, open a Claude Code session and paste this request:
Using planetas.csv, make an Excel file called resumen.xlsx. Don't change planetas.csv.- A sheet called "datos" with one row per planet (the rows with default_flag = 1).- A sheet called "resumen" with how many planets each method discovered and what percentage of the total they are.- In "resumen", every number has to be an Excel formula that reads the "datos" sheet, not a typed-in value.When you're done, tell me how many rows "datos" has and which formula ended up in the Transit count cell.Look at how the instruction is put together:
- The first line sets the permission boundary on your files: it can read
planetas.csv, it's not allowed to change it, and its output goes toresumen.xlsx. - The three bullets in the middle give it your data rule (
default_flag = 1to get one row per planet) and the audit rule (Excel formulas that read the"datos"sheet). - The last line asks for two concrete facts you can check in seconds when you open the file: how many rows ended up in
"datos"and which formula it wrote for Transit. It's your way of checking what it did before you open Excel.
When you run this request on your computer, Claude Code may ask permission to install openpyxl or pandas if you don't have them yet. You can approve that: they're the Python tools it needs to read the table and write the .xlsx file. If your session asks permission for a command you don't recognize before creating the file, paste it to your Maestro.
What happened in the test session
In the session we ran on October 31, 2026 with Claude Code 2.1.314, the agent first inspected planetas.csv with pandas (it checked how many rows had default_flag set to 1 and made sure there were no repeated planet names or empty discovery-method cells), then built resumen.xlsx with openpyxl, recalculated the workbook with LibreOffice to confirm the formulas gave the expected counts, and checked with md5sum that planetas.csv hadn't changed by a single byte. This was its answer:
Hice `resumen.xlsx` en `exoplanetas/resumen.xlsx`. No toqué `planetas.csv`.- **Filas de "datos":** 6,451 planetas con `default_flag = 1`, más la fila de encabezados. No había nombres de planeta repetidos entre esas filas.- **Fórmula del conteo de Transit:** la celda `B2` de "resumen" tiene `=COUNTIF(datos!$D$2:$D$6452,A2)`. Da 4,785 al recalcular el archivo con LibreOffice.**Hoja "resumen":**- Hay una fila por cada uno de los 11 métodos de descubrimiento. Todos los conteos son fórmulas `COUNTIF` sobre la hoja "datos".- Cada porcentaje es la fila dividida entre el total (`=B2/$B$13`). El total es `=SUM(B2:B12)` y suma 6,451.- Transit es el 74.2 % del total y Radial Velocity el 18.7 %.Los métodos se listaron por orden de conteo y sus nombres están escritos a mano en la columna A. Si cambiaras los datos, los conteos se actualizarían, pero un método nuevo no aparecería solo.Notice three parts of that answer:
- It confirms it respected your original file and your business rule. It didn't touch
planetas.csv, and the"datos"sheet ended up with the 6,451 unique-planet rows plus the header row (6,452 rows in all). - It hands you the pieces to audit the sheet. It tells you the exact formula in cell B2 (
=COUNTIF(datos!$D$2:$D$6452,A2)), what it gives when recalculated (4,785, which is74.2%), which formula adds the total in B13 (=SUM(B2:B12)), and that the sum matches the6,451planets you already knew from Module 2. - It warns you about a limit in its own design. In the last paragraph it explains that it typed the 11 method names into column A, ordered by count. If the rows for those 11 methods change, the
COUNTIFformulas update; but if a 12th method shows up in the data tomorrow, it won't be added to the table on its own. That warning saves you surprises and leaves it to you to decide whether that's enough for your report or whether you'd rather ask for a different design.
One detail when you open resumen.xlsx on your computer: if your Excel is set to another language, the formula bar shows the function names in that language (in Spanish, for example, =CONTAR.SI(datos!$D$2:$D$6452,A2) and =SUMA(B2:B12) instead of COUNTIF and SUM). It's exactly the same formula. Inside, .xlsx files store function names in English, and Excel translates them to the language your app is installed in. If your resumen.xlsx came out with a different structure or different numbers, tell your Maestro what you got back.
Warning: Your work files and what the agent can see
With your own Excel workbooks, the same minimum-access rule applies: put only the files Claude Code needs to read for that task in the working folder, always ask it to write to a new file without changing the original, and before using your organization's files (like payroll, customers or finance), confirm which data your company allows you to process with an AI tool.
Try it
Run this page's request in your exoplanetas folder. When Claude Code finishes, check its answer in your session before you open the file:
- Confirm it tells you
planetas.csvis unchanged and thatresumen.xlsxwas created in your folder. - Check that the
"datos"sheet has 6,451 planet rows (6,452 counting the header) and that the"resumen"total adds up to 6,451. - Check that the Transit count cell has a
COUNTIFformula (or its name in your Excel's language) pointing at the"datos"sheet, giving 4,785.
Then answer this question: