# TabularDataExport

## Content

# Namespace: TabularDataExport

## Table of contents

### Type aliases

- [CheckCancelCallback](TabularDataExport#checkcancelcallback)
- [CsvSettings](TabularDataExport#csvsettings)
- [OnProgressCallback](TabularDataExport#onprogresscallback)
- [TabularDataExportResult](TabularDataExport#tabulardataexportresult)
- [TabularDataSettings](TabularDataExport#tabulardatasettings)

### Functions

- [exportDocument](TabularDataExport#exportdocument)

## Type aliases

### <a id="checkcancelcallback" name="checkcancelcallback"></a> CheckCancelCallback

Ƭ **CheckCancelCallback**: () => `boolean`

#### Type declaration

▸ (): `boolean`

Defines a callback that determines whether export should be canceled.

**`example`**
```ts
const shouldCancel: CheckCancelCallback = () => false;
```

##### Returns

`boolean`

`true` to cancel the export; otherwise, `false`.

___

### <a id="csvsettings" name="csvsettings"></a> CsvSettings

Ƭ **CsvSettings**: `Object`

Represents CSV export settings.

**`example`**
```ts
const settings: CsvSettings = {
	colSeparator: ',',
	rowSeparator: '\n',
	outputType: 'plain',
};
```

#### Type declaration

| Name | Type | Description |
| :------ | :------ | :------ |
| `colSeparator?` | `string` | Gets or sets the column separator character. |
| `outputType?` | ``"zip"`` \| ``"plain"`` | Gets or sets how CSV output is produced.  **`remarks`** Accepted values: - `'zip'`: Export each table as a separate file in a ZIP archive. - `'plain'`: Combine all tables into a single CSV string. |
| `quotationSymbol?` | `string` | Gets or sets the quotation symbol. |
| `rowSeparator?` | `string` | Gets or sets the row separator character. |
| `tableSeparator?` | `string` | Gets or sets the table separator character. |

___

### <a id="onprogresscallback" name="onprogresscallback"></a> OnProgressCallback

Ƭ **OnProgressCallback**: (`pageNumber`: `number`) => `void`

#### Type declaration

▸ (`pageNumber`): `void`

Defines a callback invoked after each page is rendered.

**`example`**
```ts
const onProgress: OnProgressCallback = (pageNumber) => console.log(pageNumber);
```

##### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `pageNumber` | `number` | The one-based page number that has finished rendering. |

##### Returns

`void`

___

### <a id="tabulardataexportresult" name="tabulardataexportresult"></a> TabularDataExportResult

Ƭ **TabularDataExportResult**: `Object`

Represents the result of a tabular data export.

**`example`**
```ts
const result: TabularDataExportResult = {
	data: 'a,b,c',
	download: (name) => console.log(name),
};
```

#### Type declaration

| Name | Type | Description |
| :------ | :------ | :------ |
| `data` | `Blob` \| `string` | Gets or sets the exported content.  **`remarks`** Returns a `string` for `'plain'` output and a `Blob` for `'zip'` output. |
| `download` | (`filename?`: `string`) => `void` | Gets or sets the function that triggers a browser download of the export result.  **`example`** ```ts const result = {} as TabularDataExportResult; result.download('data.csv'); ``` |

___

### <a id="tabulardatasettings" name="tabulardatasettings"></a> TabularDataSettings

Ƭ **TabularDataSettings**: `Object`

Represents tabular data export settings.

**`example`**
```ts
const settings: TabularDataSettings = {
	format: 'csv',
	csvSettings: { outputType: 'plain' },
};
```

#### Type declaration

| Name | Type | Description |
| :------ | :------ | :------ |
| `csvSettings?` | [`CsvSettings`](TabularDataExport#csvsettings) | Gets or sets CSV export settings. |
| `format?` | ``"csv"`` | Gets or sets the export format.  **`remarks`** Accepted values: - `'csv'` |

## Functions

### <a id="exportdocument" name="exportdocument"></a> exportDocument

▸ **exportDocument**(`source`, `settings?`, `onProgress?`, `checkCancel?`): `Promise`<[`TabularDataExportResult`](TabularDataExport#tabulardataexportresult)\>

Exports a PageDocument or VDomRenderer to tabular data format.

**`example`**
```ts
const result = await exportDocument(report, { format: 'csv' });
result.download('report.csv');
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `source` | [`PageDocument`](../classes/Core.PageDocument) \| `VDomRenderer` | The source document or renderer to export. |
| `settings?` | [`TabularDataSettings`](TabularDataExport#tabulardatasettings) | The tabular data export settings. |
| `onProgress?` | [`OnProgressCallback`](TabularDataExport#onprogresscallback) | The callback invoked after each page is rendered. |
| `checkCancel?` | [`CheckCancelCallback`](TabularDataExport#checkcancelcallback) | The callback invoked before rendering each page. Return `true` to cancel. |

#### Returns

`Promise`<[`TabularDataExportResult`](TabularDataExport#tabulardataexportresult)\>

A promise that resolves to the export result.
