> For the complete documentation index, see [llms.txt](https://cgps.gitbook.io/data-flo/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cgps.gitbook.io/data-flo/reference-guide/export-to-google-sheet.md).

# export-to-google-sheet

## Description

<mark style="color:purple;">`export-to-google-sheet`</mark> *adaptor exports data to an existing Google Sheets spreadsheet*.

Private spreadsheets should be shared with <mark style="color:blue;"><data-flo@data-flo.iam.gserviceaccount.com></mark> and given edit permission.

## Inputs

**`data`**\
Type: `datatable`\
Required: Yes\
The data to be exported to the Google Sheets.

**`url`**\
Type: `text`\
Required: Yes\
A valid URL of a Google Spreadsheet to be updated. The Spreadsheet should be shared with <mark style="color:blue;"><data-flo@data-flo.iam.gserviceaccount.com></mark> and given `Can Edit` permission.

**`sheet name`**\
Type: `text`\
Required: No\
The title of the sheet (tab) to which data will be exported. If unspecified, the first sheet in the spreadsheet will be used.

**`header row`**\
Type: `number`\
Required: No\
The row number of the sheet row which contains column headers. If unspecified, it defaults to `1` (the first row).

**`id column`**\
Type: `text`\
Required: Yes\
The name of the column that contains the unique row IDs shared by `data` and the Google Sheets spreadsheet.

**`append rows`**\
Type: `boolean`\
Required: No\
When set to `False, only existing rows will be updated. When set to` True`, existing rows will be updated and new (non-existing) rows will be added to the end of the Google Sheets spreadsheet. If unspecified, defaults to` True\`.

**`append columns`**\
Type: `boolean`\
Required: No\
When set to `False, only existing columns will be updated. When set to` True`, existing columns will be updated and new (non-existing) columns will be added to the end of the Google Sheets spreadsheet. If unspecified, defaults to` True\`.

**`resize sheet`**\
Type: `boolean`\
Required: No\
Specifies whether to resize the Google Sheets spreadsheet when more rows and columns are needed. If unspecified, defaults to `True`.

## Outputs

**`updated row ids`**\
Type: `list`\
A list of existing row IDs which have been updated.

**`created row ids`**\
Type: `list`\
A list of new row IDs which have been created when `append rows` is set to `True`.

**`skipped row ids`**\
Type: `list`\
A list of row IDs which in `data` which are missing from the Google Sheets spreadsheet when `append rows` is set to `False`.

**`appended columns`**\
Type: `list`\
A list of columns appended to the Google Sheets spreadsheet when `append columns` is set to `True`.

## Examples

### Example 1: Default behaviour.

#### Inputs:

`data:`

| id | code | countries      |
| -- | ---- | -------------- |
| 1  | GB   | United Kingdom |
| 2  | TR   | Turkey         |
| 3  | US   | United States  |

`url:` <https://drive.google.com/file/d/7891011/view?usp=sharing>

`sheet name:` *null (empty)*

`header row:` *null (empty)*

`id column:` id

`append rows:` *null (empty)*

`append columns:` *null (empty)*

`resize sheet:` *null (empty)*

#### Outputs:

`updated row ids`: *null (empty)*

`created row ids`:

1. 1
2. 2
3. 3

`skipped row ids`: *null (empty)*

`appended columns`:

1. id
2. code
3. countries

-> Exported datatable to an existing google sheet.
