published fresh until

How do I let an agent edit my Excel file without breaking it?

Summary Edit designated inputs, preserve formulas, and inspect recalculation status and not_computed. The xlsx skill’s formula restrictions describe its runtime; its LICENSE.txt contains Apache-2.0 terms. Preserve macros when loading an xlsm file with keep_vba=True

Not for comparing two Excel or CSV files for changed rows; see compare-two-excel-or-csv-files-find-missing-and-changed-rows-with-pandas

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

As of November 2026, edit a copy within the workbook’s designated inputs and preserve formulas. The xlsx skill describes a specific openpyxl/LibreOffice runtime; its function restrictions are not a universal statement about all LibreOffice builds.

Do first: identify permitted cells, formulas, macros and external links before saving, following the skill’s editing precautions.

The problem

You give an agent an existing workbook and ask for a change. It comes back with formulas replaced by numbers, links to other files broken, macros missing or #NAME? in cells. The agent's skill for spreadsheets is the place that lists these traps. The text below summarises the current xlsx skill in anthropics/skills. Its licence field points to LICENSE.txt, which now contains Apache-2.0 terms.

Rules for editing an existing file

  • Match the file's own conventions; they override the skill's defaults. Find the designated input cells first (a distinct font colour, fill or shading marks them), write only there, and leave every existing formula untouched.
  • Do not add example rows to a file you were asked to edit.
  • Use formulas, not typed results, so the sheet still recalculates.
  • Recalculate and read the report. openpyxl saves formulas with no cached values, so pandas and previewers see empty cells until the file is recalculated. The skill's scripts/recalc.py uses LibreOffice on a copy, writes only computed values back into the file and prints JSON (status, total_formulas, total_errors, an error summary, and not_computed for formulas it cannot evaluate even on success). errors_found still exits 0, so read the status, not the exit code. If an error might predate you, prove it by loading the original with data_only=True.
  • A clean recalc is not proof the numbers are right: an off-by-one range gives a clean file with wrong values.

Traps listed in the skill

  • Reading a model needs two loads: data_only=True gives values without formulas, the default gives formulas without values.
  • Saving a workbook opened with data_only=True permanently replaces every formula with a literal.
  • .xlsm loses its macros unless you open with keep_vba=True.
  • Merged cells: write only the top-left anchor.
  • A sheet name with a space must be quoted in a reference: ='Assumptions Inputs'!$B$5.
  • External links: a formula such as ='[1]Returns Analysis'!$B$2 points at another file on disk. Re-saving with openpyxl strips the cached value; recalc.py lists the external-link formula under not_computed and leaves it unchanged until Excel computes it. Read the values from the original with data_only=True first, and keep the formulas.
  • Function support: the skill bans XLOOKUP, XMATCH, SORT, FILTER, UNIQUE and SEQUENCE for its runtime. It says newer LibreOffice builds can evaluate them, but warns that missing spill metadata in an openpyxl-written file can leave a partial result with zero reported formula errors. Its suggested alternatives are INDEX/MATCH and sorting, filtering and deduplicating in Python (skill). For that runtime, the skill says six newer functions (TEXTJOIN, CONCAT, IFS, SWITCH, MAXIFS, MINIFS) work only with an _xlfn. prefix; bare, they give #NAME?.

How to use this

Tell the agent which sheet and cells may change, to work on a copy, to run the recalculation, and to report any cell outside the input area that changed. Diffing the formulas of the original against the result is my suggestion and is not part of the skill.

What it does not cover

It requires LibreOffice for recalculation. It does not promise that Excel's UI features (pivot tables, slicers, charts made in Excel) survive a round trip through openpyxl; those features require a separate preservation check. For building models from scratch and recalculating without Excel, see the existing threads on the financial model builder plugin and on recalculating openpyxl models.

Sources

Started from a post by @Anthropic, packaged by the editor. Original post

Subjects

More in agent skills

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I let an agent edit my Excel file without breaking it?
Summary: Edit designated inputs, preserve formulas, and inspect recalculation status and `not_computed`. The xlsx skill’s formula restrictions describe its runtime; its LICENSE.txt contains Apache-2.0 terms. Preserve macros when loading an xlsm file with `keep_vba=True`
Copy for agent
get the whatworks thread agent-edits-existing-excel-workbook-without-breaking-it and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread agent-edits-existing-excel-workbook-without-breaking-it
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks