# Export To

## Overview

The "Export Data" interaction enables users to download data from your Data Table or Pivot Table components to their local device. This is ideal for scenarios where you want:

* Users to analyze data offline in spreadsheet applications
* Create backups or snapshots of current data
* Share data with stakeholders who don't have Salesforce access
* Generate reports in formats compatible with other systems

### Key Features

The Export Data interaction provides flexible options for file format, encoding, and user experience. You can configure it to show a dialog with export options, or streamline the process by exporting directly with predefined settings.

**Available Components**: This interaction is only available for the [**Data Table**](https://docs.avonnicomponents.com/dynamic-components/components/data-table) and [**Pivot Table**](https://docs.avonnicomponents.com/dynamic-components/components/pivot-table) components.

***

## Tutorials

See practical examples and learn how to implement specific scenarios using this interaction:

* [**How to Export Data from a Data Table**](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/data-table/how-to-export-data)

***

## How it Works

1. **User Action**: The user interacts with a component (e.g., clicks an "Export" button) to trigger the export.
2. **Export Dialog (Optional)**: If enabled, a dialog appears that allows the user to choose the export format, encoding, and file name.
3. **Data Preparation**: The Data Table or Pivot Table gathers the visible/filtered data to be exported.
4. **File Generation**: The system generates the file in the selected format.
5. **Download**: The file downloads to the user's device with the specified name.
6. **Post-Export Actions (Optional)**: You can configure actions to run after the export completes (e.g., display a confirmation toast).

***

## Configuration

The Export Data interaction is configured directly on your Data Table or Pivot Table component. Access the component's properties panel and add the "Export Data" interaction under the "Header Click Actions". The following settings control how the export behaves.

#### Default File Name

The name that will be used for the downloaded file. This can be static text or dynamic, using resources.

**Example**: `Contact_Report_2024`.

#### Default Export View

Choose how the data should be formatted in the export:

* **Formatted Report**: Exports data with formatting preserved, similar to how it appears on screen. Better for presentation and readability.
* **Detailed Report**: Exports raw data values without formatting. Better for data analysis and manipulation in external tools.

#### Available File Format

Select which file formats users can choose from when exporting:

* **CSV**: Comma-separated values file. Universal format compatible with all spreadsheet applications. Best for simple data exports and maximum compatibility.
* **Excel**: Microsoft Excel format (.xlsx). Preserves formatting and supports multiple sheets. Best for complex reports that require formatting or for recipients who primarily use Excel.

You can enable one or both formats depending on your users' needs.

#### Default Encoding Type

Select the character encoding for the exported file. This ensures special characters and international text display correctly:

* **UTF-8**: Universal encoding supporting all languages and special characters. Recommended for most use cases.
* **UTF-16**: Alternative Unicode encoding. Use if required explicitly by downstream systems.
* **Windows-1252**: Western European character set. Use only for legacy systems that don't support UTF-8.
* **ISO-8859-1**: Latin alphabet encoding. Use for basic text without international characters.

<mark style="background-color:green;">**Tip**</mark>: When in doubt, choose UTF-8 for maximum compatibility.

#### Hide Export Dialog

Toggle this option to control whether users see an export options dialog:

* **Disabled (Dialog Shown)**: Users can choose format, encoding, and edit the file name before exporting. Provides maximum flexibility.
* **Enabled (Dialog Hidden)**: Export occurs immediately using the default settings. Provides a streamlined, one-click export experience.

**When to Hide the Dialog**: Enable this when you want a simple, quick export process, and your users don't need to choose between formats or change settings.

***

## Important Considerations

* **Component Restriction**: The Export Data interaction is only available for Data Table and Pivot Table components. You cannot export data directly from other component types.
* **Filtered Data**: Exports respect any filters applied to the Data Table or Pivot Table. Only visible/filtered data will be exported.
* **Data Limits**: Large datasets may take longer to export. Consider adding a loading indicator or toast message to inform users the export is processing.
* **File Naming**: Avoid special characters in file names that might not be compatible across all operating systems (`/ \ : * ? " < > |`).
* **Browser Permissions**: Users may need to grant download permissions in their browser on first use.
* **Data Security**: Be mindful of what data you're allowing to be exported. Ensure users have appropriate permissions to access the data being exported.
* **Formatting**: When using "Formatted Report" view, complex formatting may not translate perfectly to all file formats. Test with your specific data types.
* **Pivot Table Exports**: When exporting from Pivot Tables, the data is exported in its pivoted structure, not as the original flat data.

***

## In Summary

The Export Data interaction provides a powerful way to give users access to their Data Table and Pivot Table data outside of Salesforce. By configuring the file format, encoding, and dialog options appropriately for your use case, you can create export experiences that range from simple one-click downloads to flexible user-controlled exports with multiple format options.
