# textxport

(plugins.textxport)

## Overview

The `TextXport` plugin provides functionality for exporting data from a foundset into text-based formats like `.tab` or `.csv`, enabling flexible data management. Exports can be customized with separators and headers depending on requirements.

TextXport supports two main approaches for exporting data. The `createExporter` method allows for setting up complex export configurations, while `textExport` methods provide simpler, direct options for exporting with various levels of customization.

The `createExporter` method generates an export setup for a specified foundset, allowing configuration of the data separator and the inclusion of headers. This is useful for more advanced export workflows. The `textExport` methods perform direct exports to text-separated formats, such as tab-separated or comma-separated values. These methods allow specifying the foundset, data providers, separator, and header options to customize the exported output.

## **Returned Types**

[TabExporter](https://docs.servoy.com/reference/servoyextensions/server-plugins/textxport/tabexporter),[DataProviderExport](https://docs.servoy.com/reference/servoyextensions/server-plugins/textxport/dataproviderexport),

## Properties Summarized

| Type | Name | Summary |
| ---- | ---- | ------- |

## Methods Summarized

| Type                                                                                                   | Name                                                                                                                          | Summary                                    |
| ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| [TabExporter](https://docs.servoy.com/reference/servoyextensions/server-plugins/textxport/tabexporter) | [createExporter(foundSet, separator, exportHeader)](#createexporter-foundset-separator-exportheader)                          | Create exporter for easier export set up.  |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)                           | [textExport(foundSet, dataProviderIds)](#textexport-foundset-dataproviderids)                                                 | Export to text 'separated value' data (\*. |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)                           | [textExport(foundSet, dataProviderIds, separator)](#textexport-foundset-dataproviderids-separator)                            | Export to text 'separated value' data (\*. |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)                           | [textExport(foundSet, dataProviderIds, separator, exportHeader)](#textexport-foundset-dataproviderids-separator-exportheader) | Export to text 'separated value' data (\*. |

## Properties Detailed

## Methods Detailed

### createExporter(foundSet, separator, exportHeader)

Create exporter for easier export set up. Can either use this method (for more complex exports) or textExport(...) API

**Parameters**

* [JSFoundSet](https://docs.servoy.com/reference/servoycore/dev-api/database-manager/jsfoundset) **foundSet** the foundset to export with
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **separator** the separator of the data
* [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) **exportHeader** export a header

**Returns:** [TabExporter](https://docs.servoy.com/reference/servoyextensions/server-plugins/textxport/tabexporter) A TabExporter object for easier export setup.

**Sample**

```js
//export with ';' separator and no header
var exporter = plugins.textxport.createExporter(forms.form1.foundset,';',false);
```

### textExport(foundSet, dataProviderIds)

Export to text 'separated value' data (\*.tab/\*.csv)

**Parameters**

* [JSFoundSet](https://docs.servoy.com/reference/servoycore/dev-api/database-manager/jsfoundset) **foundSet** the foundset to export with
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **dataProviderIds** the ids of the dataproviders

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) A String containing the exported text data with default separator (tab) and no header.

**Sample**

```js
//export with default separator(tab) and no header
var dataToBeWritten = plugins.textxport.textExport(forms.form1.foundset,['id','name']);
```

### textExport(foundSet, dataProviderIds, separator)

Export to text 'separated value' data (\*.tab/\*.csv)

**Parameters**

* [JSFoundSet](https://docs.servoy.com/reference/servoycore/dev-api/database-manager/jsfoundset) **foundSet** the foundset to export with
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **dataProviderIds** the ids of the dataproviders
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **separator** the separator of the data

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) A string containing the exported data in the specified text-separated format.

**Sample**

```js
//export with ';' separator and no header
var dataToBeWritten = plugins.textxport.textExport(forms.form1.foundset,['id','name'],';');
```

### textExport(foundSet, dataProviderIds, separator, exportHeader)

Export to text 'separated value' data (\*.tab/\*.csv)

**Parameters**

* [JSFoundSet](https://docs.servoy.com/reference/servoycore/dev-api/database-manager/jsfoundset) **foundSet** the foundset to export with
* [Array](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/array) **dataProviderIds** the ids of the dataproviders
* [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) **separator** the separator of the data
* [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) **exportHeader** true for exporting with the table header, false for not

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) A String containing the exported text data with the specified separator and header (if exportHeader is true).

**Sample**

```js
//export with ';' separator and header
var dataToBeWritten = plugins.textxport.textExport(forms.form1.foundset,['id','name'],';',true);
```

***
