> For the complete documentation index, see [llms.txt](https://docs.avonnicomponents.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avonnicomponents.com/flow/tutorials/components/pivot-table/export-a-pivot-table-and-add-header-actions.md).

# Export a Pivot Table and Add Header Actions

Add Export and Refresh buttons to a Pivot Table header, so users download the summary as Excel or CSV and reload the numbers without leaving the screen.

Before the Monday pipeline meeting, a sales manager wants the summary in Excel to paste into the deck, and fresh numbers after a colleague moves a deal. Two buttons in the Pivot Table header cover both: **Export** downloads the table as it appears, with its totals, and **Refresh** reruns the query.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FwK1Y55NP8F3yzfMv534r%2Fpivot-table-export-a-pivot-table-and-add-header-actions-result.png?alt=media" alt="Pivot Table with Export and Refresh buttons in its header above a pipeline summary"><figcaption><p>Export and Refresh sit in the table header.</p></figcaption></figure>

## Before you start

* A screen flow with a Pivot Table on **Opportunity**, built as in [Show a Pipeline Summary and Drill Into Any Cell](https://docs.avonnicomponents.com/flow/tutorials/components/pivot-table/show-a-pipeline-summary-and-drill-into-any-cell.md).

## Steps

{% stepper %}
{% step %}

### Add the two buttons

Select the Pivot Table on the screen and click **Open Component Builder**. In the **Header** group of the **Properties** tab, add two **Actions**:

| Label     | Name      | Icon Name          |
| --------- | --------- | ------------------ |
| `Export`  | `export`  | `utility:download` |
| `Refresh` | `refresh` | `utility:refresh`  |

Then set **Visible Actions Buttons** to `2`, so both show as buttons instead of a menu.

An action needs a **Name**, plus a **Label** or an **Icon Name**, or it does not appear. The **Name** is what the interactions below point to.
{% endstep %}

{% step %}

### Wire Export to the Export To interaction

Open the **Interactions** tab. Under **Header Action Click**, add an interaction:

1. **Target Name**: pick **Export** in the list. The picker shows each header action by its label and stores its name, `export`.
2. **Type**: **Export To**.
3. **Default File Name**: `Pipeline review`.
4. **Default Export View**: **Formatted Report**.
5. **Available File Formats**: **Excel** and **CSV**.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FiGKePWpkW0AJLvw7lA9E%2Fpivot-table-export-a-pivot-table-and-add-header-actions-interaction.png?alt=media" alt="Interactions tab with a Header Action Click on Export set to Export To, Formatted Report view and Excel and CSV formats" width="320"><figcaption><p>The Export button runs Export To.</p></figcaption></figure>

[Export To](https://docs.avonnicomponents.com/flow/component-builder/interactions-panel/export-to.md) describes every setting of the interaction.
{% endstep %}

{% step %}

### Pick the export view

Both views export the same grid: the same rows, columns and totals as the screen. They differ in how the values are written.

| Default Export View  | What lands in the file                                                                         | Best for                                 |
| -------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------- |
| **Formatted Report** | Values formatted as on screen: currency, percentages, dates. Excel cells keep a number format. | Sharing or presenting the summary        |
| **Details Only**     | The same values without formatting.                                                            | Formulas, or importing into another tool |

Users can still switch views in the export dialog. **Default Export View** only sets the starting choice.
{% endstep %}

{% step %}

### Wire Refresh to Refresh Query

Still under **Header Action Click**, add a second interaction:

1. **Target Name**: pick **Refresh** in the list (stored as `refresh`).
2. **Type**: **Refresh Query**.

It reruns this Pivot Table's query and redraws the table with the current records. There is nothing else to set.
{% endstep %}

{% step %}

### Save and test

Save the flow and click **Debug**. The header shows **Export** and **Refresh** next to the title.

Click **Export**. A dialog titled **Export** opens with **File Name** set to `Pipeline review`, **Formatted Report** selected under **Export View**, and **Excel Format .xlsx** under **Format**. With Excel and CSV both allowed, **Format** offers **Excel Format .xls**, **Excel Format .xlsx** and **Comma Delimited .csv**; **Encoding Type** appears only for the CSV format. Click **Export**: the browser downloads `Pipeline review.xlsx`, laid out like the table.

Change the amount of one deal in another tab, then click **Refresh**: the cell and its totals update.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FTZWMwqft5pStQi4zHzug%2Fpivot-table-export-a-pivot-table-and-add-header-actions-dialog.png?alt=media" alt="Export dialog with file name Pipeline review, Formatted Report selected as export view and Excel Format .xlsx as format" width="480"><figcaption><p>The export dialog opens with the defaults set in the interaction.</p></figcaption></figure>
{% endstep %}
{% endstepper %}

{% hint style="info" %}
To skip the dialog, turn on **Hide Export Dialog** in the Export To interaction. The file downloads at once with the default name and view. If both Excel and CSV are available, it downloads as `.xlsx`. With no **Default File Name**, the file is named after the object, here `Opportunity`.
{% endhint %}

## Troubleshooting

<details>

<summary>A button does not appear in the header</summary>

The action has no **Name**, or neither a **Label** nor an **Icon Name**. Check also that **Hidden** is off on the action and **Hide Actions** is off in the **Header** group.

</details>

<details>

<summary>Clicking the button does nothing</summary>

No **Header Action Click** interaction targets that action. Open the interaction and check that **Target Name** shows the button's label. If you renamed the action's **Name** after wiring it, pick it again: the interaction stores the name, and `export` and `Export` are two different actions.

</details>

<details>

<summary>Accents or symbols look wrong in the CSV file</summary>

The CSV encoding does not match what the spreadsheet expects. In the dialog, pick another **Encoding Type**, such as **Unicode (UTF-8)**, or set **Default Encoding Type** in the interaction. Excel files have no encoding to pick.

</details>

<details>

<summary>The CSV file separates columns with semicolons</summary>

The user's locale writes decimals with a comma, so **Comma Delimited .csv** separates columns with semicolons, which a spreadsheet set to that locale expects. For a file separated by commas, pick **Comma Delimited (non-locale) .csv**: the dialog offers it only in those locales.

</details>

<details>

<summary>Details Only did not export the records</summary>

**Details Only** exports the summary grid, with unformatted values, not the records behind it.

</details>

## Related tutorials

* [Show a Pipeline Summary and Drill Into Any Cell](https://docs.avonnicomponents.com/flow/tutorials/components/pivot-table/show-a-pipeline-summary-and-drill-into-any-cell.md): build the Pivot Table this page starts from.
* [Show Totals, Subtotals and Stacked Summaries](https://docs.avonnicomponents.com/flow/tutorials/components/pivot-table/show-totals-subtotals-and-stacked-summaries.md): decide which totals end up in the exported file.
* [Let Users Filter a Pivot Table](https://docs.avonnicomponents.com/flow/tutorials/components/pivot-table/let-users-filter-a-pivot-table.md): add filter menus next to the Export button.


---

# 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.avonnicomponents.com/flow/tutorials/components/pivot-table/export-a-pivot-table-and-add-header-actions.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.
