# Exporting Data from AdapTable

Canonical page: https://www.adaptabletools.com/docs/handbook-exporting

- AdapTable makes it easy to Export data from AG Grid to a destination of the user's choice.
- Data is exported from AdapTable in the form of a **Report**.  There are 2 types:
  - System Reports - set of Reports shipped by AdapTable to export all, visible or selected data
  - Custom Reports - configured by end-users and typically using an Expression evaluated by [AdapTableQL](https://www.adaptabletools.com/docs/adaptable-ql-expression/index.md)
- Reports are exported using a **Report Format Type**: Excel, VisualExcel, CSV or JSON
- Each Report is exported to an **Export Destinations**, of which there are 2 also types:
  - System Destinations - provided by AdapTable: Downloadable File or Clipboard
  - Custom Destinations - bespoke destinations provided by developers (e.g. Email, Rest Api etc.)
- Developers are also able to configure many elements of export including:
  - how the export data is formatted
  - whether to run reports on a schedule

Exporting in AdapTable enables data in AG Grid to be sent (in the form of Reports) to other locations.

Exporting a Report is a straightforward, 3-step process, comprising 3 elements:

1. A [Report](#reports) - a defined set of rows and columns (provided by AdapTable or created by users)
2. A [Report Format Type](#report-format-types) - one of Excel, VisualExcel, JSON or CSV
3. An [Export Destination](#export-destinations) (either provided by AdapTable or by users)

- Export is **not** a WYSIWYG operation - AdapTable exports report **data** and not column styles or row groups etc.
- The one exception to this is the `VisualExcel` [Report Format Type](https://www.adaptabletools.com/docs/handbook-exporting-reports-format-type/index.md) which does include [Column Formatting](https://www.adaptabletools.com/docs/handbook-column-formatting/index.md)

Developers can, however, [choose whether exported data](https://www.adaptabletools.com/docs/handbook-exporting-formatting-reports/index.md) contains cell *raw* values (the default) or *display* values

**Example: Exporting in AdapTable**

Exporting Data from AdapTable

- This demo illustrates some of the exporting options in AdapTable (described in greater detail elsewhere in this section). These include:
  - a [Custom Report](https://www.adaptabletools.com/docs/handbook-exporting-reports-custom/index.md) called `Popular Frameworks` that uses an Expression to export the required data
  - a [Custom Export Destination](https://www.adaptabletools.com/docs/handbook-exporting-destinations-custom/index.md) of `Rest Endpoint` (though here we just output to the console)
  - set 2 [Formatting Reports](https://www.adaptabletools.com/docs/handbook-exporting-formatting-reports/index.md) export-formatting related rules (to export formatted cell values and use the format: 'yyyy-dd-MM' for dates)

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {ReportContext} from '@adaptabletools/adaptable';
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Export Demo',
  exportOptions: {
    appendFileTimestamp: true,
    exportDateFormat: 'yyyy-dd-MM',
    exportDataFormat: 'formattedValue',
    customDestinations: [
      {
        name: 'REST Endpoint',
        onExport: (reportContext: ReportContext) => {
          console.log('Sending to REST: Report: "' + reportContext.report.Name);
          console.log('Report data:', reportContext.reportData);
        },
      },
    ],
  },

  initialState: {
    Dashboard: {
      Tabs: [
        {
          Name: 'Demo',
          Toolbars: ['Export'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Export'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},

    Export: {
      CurrentReport: 'Popular Frameworks',
      CurrentFormat: 'JSON',
      Reports: [
        {
          Name: 'Popular Frameworks',
          ReportColumnScope: 'ScopeColumns',
          ReportRowScope: 'ExpressionRows',
          Scope: {ColumnIds: ['name', 'language']},
          Expression: '[github_stars] > 50000 ',
        },
      ],
    },
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'formatColumn-created_at',
          Scope: {ColumnIds: ['created_at']},
          DisplayFormat: {
            Formatter: 'DateFormatter',
            Options: {
              Pattern: 'yyyyMMdd',
            },
          },
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'has_projects',
            'has_pages',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'week_issue_change',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```

## Topics in this Section

| Topic                                                                                           | Description                                                                                                               |
| ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| [Reports](https://www.adaptabletools.com/docs/handbook-exporting-reports/index.md)                                | System Reports (`All Data`, `Current Layout`, `Selected Data`) and user-defined Custom Reports with AdapTableQL row scope |
| [Custom Reports](https://www.adaptabletools.com/docs/handbook-exporting-reports-custom/index.md)                  | Boolean expressions, column scope, and run-time management in the Export Wizard                                           |
| [Report Format Types](https://www.adaptabletools.com/docs/handbook-exporting-reports-format-type/index.md)        | Excel, Visual Excel, CSV, and JSON — including which destinations each format supports                                    |
| [Export Destinations](https://www.adaptabletools.com/docs/handbook-exporting-destinations/index.md)               | Download and Clipboard system destinations; optional ipushpull and OpenFin when the relevant plugins are loaded           |
| [Custom Export Destinations](https://www.adaptabletools.com/docs/handbook-exporting-destinations-custom/index.md) | Email, REST APIs, PDF, and other bespoke destinations via `onExport` or an Adaptable Form                                 |
| [Formatting Report Data](https://www.adaptabletools.com/docs/handbook-exporting-formatting-reports/index.md)      | Raw vs display values (`exportDataFormat`); custom date strings in exports (`exportDateFormat`)                           |
| [Processing Reports](https://www.adaptabletools.com/docs/handbook-exporting-processing/index.md)                  | Intercept exports with `processExport` — server-side data, cancellation, or replacing report contents                     |
| [Scheduling Reports](https://www.adaptabletools.com/docs/handbook-exporting-scheduling/index.md)                  | Run reports on a one-off or recurring schedule                                                                            |
| [Configuring Export](https://www.adaptabletools.com/docs/handbook-exporting-configuring/index.md)                 | File names, exportable columns, column headers, Excel sheet names, and fine-grained API export                            |
| [Master Detail Grids](https://www.adaptabletools.com/docs/handbook-master-detail/index.md#exporting-detail-rows)  | Exporting nested detail rows with `getDetailRows` on AG Grid master–detail grids                                          |
| [Export Technical Reference](https://www.adaptabletools.com/docs/technical-reference-exporting/index.md)          | Export Options, State, API, events, and types                                                                             |

## Reports

There are 2 types of [Reports](https://www.adaptabletools.com/docs/handbook-exporting-reports/index.md) available in AdapTable:

- System Reports - shipped by AdapTable and used in most common use cases
- Custom Reports - provided by users (in UI or in InitialState) specifying which Columns and Rows to export

- Both types of report can be exported using multiple [Report Formats](#report-format-types) to [multiple destinations](#export-destinations)
- Custom Reports contain a [Boolean Expression](https://www.adaptabletools.com/docs/adaptable-ql-expression-standard/index.md) that will be evaluated by [AdapTableQL](https://www.adaptabletools.com/docs/adaptable-ql-expression/index.md) each time the Report is run

## Report Format Types

AdapTable enables Reports to be created in 4 different Report Format Types

- Excel

- Visual Excel (includes styling)

- CSV

- JSON

## Export Destinations

By default exported Reports are available in 2 [System Export Destinations](https://www.adaptabletools.com/docs/handbook-exporting-destinations/index.md) which are shipped by AdapTable:

- as a **downloadable File** which the user can download and run as required

- sent to the **Clipboard** (for `CSV` and `JSON` Report Format Types only)

Depending on whether the appropriate [Plugin](https://www.adaptabletools.com/docs/technical-reference-plugins/index.md) is loaded, Reports can also be exported to [ipushpull](https://www.adaptabletools.com/docs/integrations-ipushpull/index.md) or [OpenFin Excel](https://www.adaptabletools.com/docs/integrations-openfin/index.md)

It is also possible to export Reports to [Custom Destinations](https://www.adaptabletools.com/docs/handbook-exporting-destinations-custom/index.md) that are supplied by developers at design-time using the `customDestinations` property in [Export Options](https://www.adaptabletools.com/docs/technical-reference-exporting/index.md).

- This enables exporting Grid data to email, PDF, REST APIs, and other locations
- But while still leveraging AdapTable's Export, Expressions, Scheduling and State Management functionality

## Customising Reports

AdapTable provides many [Export Options](https://www.adaptabletools.com/docs/technical-reference-exporting/index.md) to configure the behaviour or appearance of Reports.

These options include (among others):

- configuring which Reports, Report Format Types or Destinations are available to the user in the UI
- setting the name of the downloaded file
- customizing the exported data e.g. to export formatted data or bespoke formats for Date columns
- processing the report - to run it on the server, or to cancel the export
- choosing whether to include Column Headers in the exported data
- configuring which Columns can be fully excluded from Export

See the [Configuring Reports](https://www.adaptabletools.com/docs/handbook-exporting-configuring/index.md), [Formatting Report Data](https://www.adaptabletools.com/docs/handbook-exporting-formatting-reports/index.md) and [Processing Reports](https://www.adaptabletools.com/docs/handbook-exporting-processing/index.md) topics for more information

## Using Export

Reports are managed at runtime via the Export section of the [Settings Panel](https://www.adaptabletools.com/docs/ui-settings-panel/index.md).

This lists the details of all Reports, and associated Report Format Types, in Adaptable State with options to:

- _Run_ with a dropdown showing all available destinations
- _Create_ (Custom Reports only - via the Export Wizard)
- _Edit_ (Custom Reports only - via the Export Wizard)
- _Delete_
- _Suspend_
- _[Share](https://www.adaptabletools.com/docs/handbook-team-sharing/index.md)_ (if Team Sharing is running)
- _[Schedule](https://www.adaptabletools.com/docs/handbook-exporting-scheduling/index.md)_ (so they run at a specified time)

### Running Reports

Reports can be run from a number of places:

- Export [Toolbar](https://www.adaptabletools.com/docs/ui-dashboard/index.md#tabs-and-toolbars) in the Dashboard
- Export [Tool Panel](https://www.adaptabletools.com/docs/ui-tool-panel/index.md) in the AdapTable ToolPanel Component
- Export Status Bar Panel in the [AdapTable Status Bar](https://www.adaptabletools.com/docs/ui-status-bar/index.md)
- Export Section in the [Settings Panel](https://www.adaptabletools.com/docs/ui-settings-panel/index.md)
- Via the [Context Menu](https://www.adaptabletools.com/docs/ui-context-menu/index.md) (`Selected Data` Report only)
- Programmatically via methods in the [Export API](https://www.adaptabletools.com/docs/technical-reference-exporting/index.md) section of AdapTable API

### FAQ

**Is the export 'live' - will it update when the grid data changes?**
No - export is a one time only snapshot.
However AdapTable contains Modules (all available as Plugins) which do offer Live Data e.g. [ipushpull](https://www.adaptabletools.com/docs/integrations-ipushpull/index.md) and [OpenFin](https://www.adaptabletools.com/docs/integrations-openfin/index.md)

**Do you include column names in the exported data?**
Yes — column headers are included by default. Set `skipColumnHeaders` in [Export Options](https://www.adaptabletools.com/docs/technical-reference-exporting/index.md) to exclude them (for all exports or for selected reports).

**Is there an option when just copying to the clipboard to exclude column names?**
Yes — use the same `skipColumnHeaders` property (see [Configuring Export](https://www.adaptabletools.com/docs/handbook-exporting-configuring/index.md#skipping-column-headers)).

**Is there a limit on the number of reports that I can create?**
No, reports like all other Adaptable Objects are unlimited.

**Is there a limit on how much data I can export?**
AdapTable doesn't set a limit as everyone's computer and hardware is different.
It also depends which destination you are sending to.
As a general rule if sending to Excel we advise not exporting more than 300,000 cells.

### Exporting huge data sets to Excel

Because exporting takes place in the browser, there is a memory limit on how much data can be sent to Excel.

If you want to send a lot of raw data to Excel there are a few options:

- export the data instead as csv as that has a much lower memory footprint
- create a Custom Export Destination which will allow you to open / create the Excel file on your client
- run the `getReportDataForReport` function in [Export API](https://www.adaptabletools.com/docs/technical-reference-exporting/index.md) and then send it to Excel locally

**Why can I not see the _Excel_ Report Format Type?**
Make sure you have the correct [AG Grid Modules](https://www.ag-grid.com/javascript-data-grid/modules/) loaded (i.e. `ExcelExportModule`) for this option to be available.

**Can I run a Report even though it will display data not in AdapTable?**
Yes, you can process the Report each time it runs and leverage that to provide any data you require.

**Can I hide some of the shipped Reports or Format Types?**
Yes, both are available via `systemReportNames` and `systemReportFormats` properties in [Export Options](https://www.adaptabletools.com/docs/technical-reference-exporting/index.md) respectively

**Can I export the display formatted cell value in the column and not the raw value?**
Yes by setting the `exportDataFormat` property in [Export Options](https://www.adaptabletools.com/docs/technical-reference-exporting/index.md).
