> ## Documentation Index
> Fetch the complete documentation index at: https://docs.doconda.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How do I edit an Excel file with AI and keep its formulas?

> Upload the .xlsx and ask for the change with operation edit: Doconda touches only what you ask, and changes go in as real formulas, not pasted numbers.

To edit an Excel file with AI and keep its formulas, upload it and ask for the change in a sentence with
`operation: "edit"`. Doconda changes only what you ask, leaves the rest of the sheet identical and writes the changes
as real formulas, not pre-computed numbers.

## Steps

1. Store your API key in `DOCONDA_API_KEY` and install the SDK (`pip install doconda` or `npm install @doconda/sdk`).
2. Upload the Excel file with `files.upload`.
3. Ask for the change, check the report and download the `.xlsx`.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  from pathlib import Path
  from doconda import Doconda

  doconda = Doconda()  # reads the key from DOCONDA_API_KEY
  file = doconda.files.upload("sales.xlsx")
  edited = doconda.documents.create(
      operation="edit",
      file=file["id"],
      prompt="Add a Margin column to the Sales sheet: revenue minus costs, with a total at the bottom",
  )
  report = doconda.documents.report(edited["id"])
  for issue in report["issues"]:
      print(issue["code"], issue["message"], issue["location"])
  Path("sales-edited.xlsx").write_bytes(doconda.documents.download(edited["id"], "xlsx"))
  ```

  ```ts TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  import { readFile, writeFile } from "node:fs/promises"
  import { Doconda } from "@doconda/sdk"

  const doconda = new Doconda()
  const file = await doconda.files.upload(await readFile("sales.xlsx"), "sales.xlsx")
  const edited = await doconda.documents.create({
    operation: "edit",
    file: file.id,
    prompt: "Add a Margin column to the Sales sheet: revenue minus costs, with a total at the bottom",
  })
  const report = await doconda.documents.report(edited.id)
  for (const issue of report.issues) console.log(issue.code, issue.message, issue.location)
  await writeFile("sales-edited.xlsx", await doconda.documents.download(edited.id, "xlsx"))
  ```
</CodeGroup>

## What you get back

* The same Excel file with the change made with formulas, and its PDF.
* A report: the result is reviewed as in [Review](/en/guides/review). Formulas with errors (`#REF!`, `#DIV/0!`…),
  broken references or a hand-typed number among identical formulas show up in `issues`, with the sheet and cells in
  `location`.
* `status`: `ready`, `ready_with_warnings`, `needs_review` or `failed`. If the request can't be turned into changes,
  `failed` with `edit_not_understood`, not charged.

## Limits

* `.xls` is accepted: the result comes out as `.xlsx`.
* With `quality: "fast"` and with `.xls`, each change arrives as an `edit.operation_applied` event with the before and
  after, and is kept in the report (`edits`).
* 50 pages maximum.

## FAQ

<AccordionGroup>
  <Accordion title="Why not let the model rewrite the sheet?">
    A model tends to return pre-computed values: the sheet looks right but stops recalculating. With `edit` the rest
    stays identical and new content goes in as formulas.
  </Accordion>

  <Accordion title="Can I just check an Excel file for errors?">
    Yes, with `operation: "review"`, no AI. It detects formula errors, broken references, numbers stored as text and
    hidden data, among others.
  </Accordion>

  <Accordion title="What about a new Excel file with formulas?">
    Use `format: "xlsx"` and a `prompt`. See [Excel with formulas from an LLM](/en/solutions/excel-formulas-llm).
  </Accordion>
</AccordionGroup>

## Keep reading

* [Edit](/en/guides/edit) and [Review](/en/guides/review).
* [Quickstart](/en/quickstart).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.