> For the complete documentation index, see [llms.txt](https://docs.trymito.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trymito.io/how-to/exporting-to-csv-and-excel/generate-code-to-create-excel-and-csv-reports.md).

# Generate code to create Excel and CSV reports

Generate an Excel or CSV file each time you run your code.

### Why generate export code

Sometimes, you don't want to just download a snapshot of the current dataframe within Mito - you want to create code that takes one of these dataframes and saves it to a CSV or Excel file. This can be particularly useful if you're automating a full analysis within Mito.

### How to generate export code

1. Open the `Home` tab in the Mito toolbar.
2. Click the `Export` dropdown then select `Download File When Running Code`.
3. Change the `File Name` to the name of the file to save.&#x20;
4. Select the export format, either `CSV` or `Excel` files.
5. Select the dataframes you want to include in the export.&#x20;
   1. Note that if you select multiple dataframes when exporting as a CSV, Mito will automatically create distinct files for each.
6. Click the `Generate Export Code` button.&#x20;
   1. This saves the exported file to disk, and also generates code that will export a file with the same configuration as well.

<figure><img src="https://2294704369-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MP_U5ZCmiamDOXEOOTC%2Fuploads%2F7RYKcBwuhwXflhbxGovg%2FScreen%20Shot%202023-11-29%20at%203.40.52%20PM.png?alt=media&amp;token=7aab7347-b707-4b44-9ea7-65882098bd76" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.trymito.io/how-to/exporting-to-csv-and-excel/generate-code-to-create-excel-and-csv-reports.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
