# Import Technical Reference

Canonical page: https://www.adaptabletools.com/docs/technical-reference-importing

## Data Import Options

| Property | Type | Description |
| --- | --- | --- |
| [fileHandlers](https://www.adaptabletools.com/docs/reference/dataimportoptions.md#filehandlers) | [`DataImportFileHandler`](https://www.adaptabletools.com/docs/reference/dataimportfilehandler.md)`<T>[]` | Custom File Handlers to use for Data Import |
| [handleImportedData](https://www.adaptabletools.com/docs/reference/dataimportoptions.md#handleimporteddata) | `(context: `[`HandleImportedDataContext`](https://www.adaptabletools.com/docs/reference/handleimporteddatacontext.md)`<T>) => Promise<void \| `[`HandleImportedDataResolution`](https://www.adaptabletools.com/docs/reference/handleimporteddataresolution.md)`>` | Function to handle the Imported Data and apply it to the Grid. If not provided then the Data will be applied to the Grid automatically. |
| [textHandler](https://www.adaptabletools.com/docs/reference/dataimportoptions.md#texthandler) | `(text: string) => T[] \| Promise<T[]>` | Handles Importing Data using text |
| [validate](https://www.adaptabletools.com/docs/reference/dataimportoptions.md#validate) | `(context: `[`DataImportValidateContext`](https://www.adaptabletools.com/docs/reference/dataimportvalidatecontext.md)`<T>) => `[`DataImportValidationError`](https://www.adaptabletools.com/docs/reference/dataimportvalidationerror.md)`[] \| undefined` | Function to validate the Imported Data |
| [_getPrimaryKeyValue](https://www.adaptabletools.com/docs/reference/dataimportoptions.md#_getprimarykeyvalue) | `(context: `[`GetPrimaryKeyValueContext`](https://www.adaptabletools.com/docs/reference/getprimarykeyvaluecontext.md)`<T>) => string \| number` | Function to get the Primary Key value for a data row (defaults to value of the primaryKey column)<br/><br/>It might change in a future version |
| [_preprocessRowData](https://www.adaptabletools.com/docs/reference/dataimportoptions.md#_preprocessrowdata) | `(context: `[`PreprocessRowDataContext`](https://www.adaptabletools.com/docs/reference/preprocessrowdatacontext.md)`<T>) => Record<string, any>` | Function to pre-process the data before it is imported<br/><br/>It might change in a future version |

`fileHandlers` entries are a [`DataImportFileHandler`](https://www.adaptabletools.com/docs/reference/dataimportfilehandler.md):

| Property | Type | Description |
| --- | --- | --- |
| [fileExtension](https://www.adaptabletools.com/docs/reference/dataimportfilehandler.md#fileextension) | `string` | Name of File Extension |
| [handleFile](https://www.adaptabletools.com/docs/reference/dataimportfilehandler.md#handlefile) | `(file: File) => Promise<T[]>` | Async function which handles the import returning a Data Record |

`handleImportedData` receives a [`HandleImportedDataContext`](https://www.adaptabletools.com/docs/reference/handleimporteddatacontext.md):

| Property | Type | Description |
| --- | --- | --- |
| [data](https://www.adaptabletools.com/docs/reference/handleimporteddatacontext.md#data) | `T[]` | Data which has been imported |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/handleimporteddatacontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

`validate` receives a [`DataImportValidateContext`](https://www.adaptabletools.com/docs/reference/dataimportvalidatecontext.md) and returns [`DataImportValidationError`](https://www.adaptabletools.com/docs/reference/dataimportvalidationerror.md) objects:

| Property | Type | Description |
| --- | --- | --- |
| [rowData](https://www.adaptabletools.com/docs/reference/dataimportvalidatecontext.md#rowdata) | `T` | Imported Row Data |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/dataimportvalidatecontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

| Property | Type | Description |
| --- | --- | --- |
| [columnId](https://www.adaptabletools.com/docs/reference/dataimportvalidationerror.md#columnid) | `string` | Column which contains the Error |
| [error](https://www.adaptabletools.com/docs/reference/dataimportvalidationerror.md#error) | `string` | The validatoin error text |

-------

## Data Import API

| Method | Returns | Description |
| --- | --- | --- |
| [openImportWizard()](https://www.adaptabletools.com/docs/reference/dataimportapi.md#openimportwizard) | `void` | Opens the Data Import Wizard |

-------

## Data Imported Event

The  Data Imported Event is published whenever data has been imported.  

### DataImportedInfo

The [`DataImportedInfo`](https://www.adaptabletools.com/docs/reference/dataimportedinfo.md) object returned by the Event contains details of the rows which have been added and / or updated by the Import.

| Property | Type | Description |
| --- | --- | --- |
| [addedRows](https://www.adaptabletools.com/docs/reference/dataimportedinfo.md#addedrows) | `IRowNode[]` | Row nodes created by this import. |
| [importData](https://www.adaptabletools.com/docs/reference/dataimportedinfo.md#importdata) | `any[]` | Raw rows that were imported, before they were matched to grid rows. |
| [updatedRows](https://www.adaptabletools.com/docs/reference/dataimportedinfo.md#updatedrows) | `IRowNode[]` | Existing row nodes updated by this import. |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/dataimportedinfo.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

### Event Subscription

Subscribing to the Event is done the same way as with all [Adaptable Events](https://www.adaptabletools.com/docs/technical-reference-adaptable-events/index.md):

```ts
api.eventApi.on('DataImported', (eventInfo: DataImportedInfo) => {
    // do something with the info
});
```
