---
title: "sheet_write"
description: "Applies one or more patches (`patches[]`) to an existing workbook, preserves cells and sheets outside them, requires `baseVersion` and appends a version of the same file id; identical content, media type and name adds no version and returns `unchanged: true`."
---

| Tool | Kind | Purpose |
| :-- | :-- | :-- |
| `sheet_write` | write | Applies one or more patches (`patches[]`) to an existing workbook, preserves cells and sheets outside them, requires `baseVersion` and appends a version of the same file id; identical content, media type and name adds no version and returns `unchanged: true`. The receipt reports `source` at the base version and `file` at the resulting version. On `conflict`, re-read the current version and redo the edit. A cell patch `{ sheet, range, cells }` writes an A1 range; a query patch `{ sheet, anchor, query }` (also needs `files:read`) runs one `sql` `SELECT` and writes every row from the `anchor` cell, keeping the template's formatting, without the data passing through the agent. Patches must not overlap. |
