> For the complete documentation index, see [llms.txt](https://utca.knowledgator.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://utca.knowledgator.com/datasources/google-sheets.md).

# Google Sheets

Actions for handling Google Sheets data

To use this actions you need to configure Google Cloude. See more:

{% content-ref url="/pages/FmiieOtdZ7EcfmHqapxN" %}
[Google Cloud](/integrations/google-cloud.md)
{% endcontent-ref %}

## Module: [implementation](/framework-structure.md#implementation).datasources.google\_sheets

***

***

## <mark style="color:green;">GoogleSheetsAction</mark>

Base Google Sheets action. Subclass of [**Action**](/core/action.md)**.**

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**client**</mark>**&#x20;(**[**GoogleCloudClient**](/apis/googlecloudclient.md)**):** Google client that will be used for access.
* <mark style="color:orange;">**name**</mark>**&#x20;(Optional\[str], optional):** Name for identification. If equals to None, class name will be used. Defaults to None.

***

***

***

## <mark style="color:green;">GoogleSheetsCreate</mark>

Create spreadsheet. Subclass of [**GoogleSheetsAction**](#googlespreadsheetsaction). Type of \
[**GoogleSheetsAction**](#googlespreadsheetsaction)**\[Dict\[str, Any], Dict\[str, Any]]**.

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"title"**</mark>**&#x20;(str):** Name of the spreadsheet;
  * <mark style="color:red;">**"sheets"**</mark>**&#x20;(List\[str], optional):** Sheets names to create. Defaults to \["Sheet1"].

#### Raises:

* **Exception:** If unable to create spreadsheet.

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"spreadsheet\_id"**</mark>**&#x20;(str):** Spreadsheet ID;

***

***

***

## <mark style="color:green;">GoogleSheetsRead</mark>

Read spreadsheet. Subclass of [**GoogleSheetsAction**](#googlespreadsheetsaction). Type of [**GoogleSheetsAction**](#googlespreadsheetsaction)**\[Dict\[str, Any], Dict\[str, Any]]**.

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"spreadsheet\_id"**</mark> **(str):** Spreadsheet ID (can be found in url: <https://docs.google.com/spreadsheets/d/>*<mark style="color:purple;">**spreadsheet\_id**</mark>*/edit#gid=0);
  * <mark style="color:red;">**"cells\_range"**</mark>**&#x20;(str):** Range of cells provided in A1 notation. Examples: "B2:C2", "A1", "Sheet1", "Sheet1!A1:B1", etc..
  * <mark style="color:red;">**"dimension"**</mark>**&#x20;(**[**Dimension**](#dimension)**, optional):** Reading dimension. May be [**Dimension**](#dimension)**.**[**ROWS**](#rows) or [**Dimension**](#dimension)**.**[**COLUMNS**](#columns). Defaults to[ **Dimension**](#dimension)**.**[**ROWS**](#rows).

#### Raises:

* **Exception:** If unable to read spreadsheet.

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"table"**</mark>**&#x20;(List\[List\[Any]]):** Table that represents sheet or part of it specified by **"cells\_range"**;

***

***

***

## <mark style="color:green;">GoogleSheetsReadBatch</mark>

Read spreadsheet batch. Subclass of [**GoogleSheetsAction**](#googlespreadsheetsaction). Type of \
[**GoogleSheetsAction**](#googlespreadsheetsaction)**\[Dict\[str, Any], List\[Dict\[str, Any]]]**.

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"spreadsheet\_id"**</mark> **(str):** Spreadsheet ID (can be found in url: <https://docs.google.com/spreadsheets/d/>*<mark style="color:purple;">**spreadsheet\_id**</mark>*/edit#gid=0);
  * <mark style="color:red;">**"cells\_ranges"**</mark>**&#x20;(List\[str]):** Ranges of cells provided in A1 notation. Examples: "B2:C2", "A1", "Sheet1", "Sheet1!A1:B1", etc..
  * <mark style="color:red;">**"dimension"**</mark>**&#x20;(**[**Dimension**](#dimension)**, optional):** Reading dimension. May be [**Dimension**](#dimension)**.**[**ROWS**](#rows) or [**Dimension**](#dimension)**.**[**COLUMNS**](#columns). Defaults to[ **Dimension**](#dimension)**.**[**ROWS**](#rows).

#### Raises:

* **Exception:** If unable to read spreadsheet.

#### Returns:

* **List\[Dict\[str, Any]]:** List of items containing tables. \
  Items expected keys:
  * <mark style="color:red;">**"table"**</mark>**&#x20;(List\[List\[Any]]):** Table that represents sheet or part of it specified by **"cells\_range"**;

***

***

***

## <mark style="color:green;">GoogleSheetsWrite</mark>

Write to spreadsheet. Subclass of [**GoogleSheetsAction**](#googlespreadsheetsaction). Type of \
[**GoogleSheetsAction**](#googlespreadsheetsaction)**\[Dict\[str, Any], Dict\[str, Any]]**.

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"spreadsheet\_id"**</mark> **(str):** Spreadsheet ID (can be found in url: <https://docs.google.com/spreadsheets/d/>*<mark style="color:purple;">**spreadsheet\_id**</mark>*/edit#gid=0);
  * <mark style="color:red;">**"cells\_range"**</mark>**&#x20;(str):** Range of cells provided in A1 notation. Examples: "B2:C2", "A1", "Sheet1", "Sheet1!A1:B1", etc..
  * <mark style="color:red;">**"value\_input\_option"**</mark>**&#x20;(**[**InputOption**](#inputoption)**, optional):** Input option can be: [**InputOption**](#inputoption)**.**[**USER\_ENTERED**](#user_entered) - All inputs treated as input from the user (enabling formatting and formulas), or[ **InputOption**](#inputoption)**.**[**RAW**](#raw) - all inputs as is. Defaults to [**InputOption**](#inputoption)**.**[**USER\_ENTERED**](#user_entered).
  * <mark style="color:red;">**"dimension"**</mark>**&#x20;(**[**Dimension**](#dimension)**, optional):** Reading dimension. May be [**Dimension**](#dimension)**.**[**ROWS**](#rows) or [**Dimension**](#dimension)**.**[**COLUMNS**](#columns). Defaults to[ **Dimension**](#dimension)**.**[**ROWS**](#rows).
  * <mark style="color:red;">**"table"**</mark>**&#x20;(List\[List\[Any]]):** Values to add to spreadsheet.

#### Raises:

* **Exception:** If unable to update spreadsheet.

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"spreadsheet"**</mark> **(Dict\[str, Any]):** Updated spreadsheet;

***

***

***

## <mark style="color:green;">GoogleSheetsWriteBatch</mark>

Write to spreadsheet batch. Subclass of [**GoogleSheetsAction**](#googlespreadsheetsaction). Type of [**GoogleSheetsAction**](#googlespreadsheetsaction)**\[Dict\[str, Any], Dict\[str, Any]]**.

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"spreadsheet\_id"**</mark> **(str):** Spreadsheet ID (can be found in url: <https://docs.google.com/spreadsheets/d/>*<mark style="color:purple;">**spreadsheet\_id**</mark>*/edit#gid=0);
  * <mark style="color:red;">**"value\_input\_option"**</mark>**&#x20;(**[**InputOption**](#inputoption)**, optional):** Input option can be: [**InputOption**](#inputoption)**.**[**USER\_ENTERED**](#user_entered) - All inputs treated as input from the user (enabling formatting and formulas), or[ **InputOption**](#inputoption)**.**[**RAW**](#raw) - all inputs as is. Defaults to [**InputOption**](#inputoption)**.**[**USER\_ENTERED**](#user_entered).
  * <mark style="color:red;">**"inputs"**</mark>**&#x20;(List\[Dict\[str, Any]]):** List of write actions. Each action contain:
    * <mark style="color:red;">**"cells\_range"**</mark>**&#x20;(str):** Range of cells provided in A1 notation. Examples: "B2:C2", "A1", "Sheet1", "Sheet1!A1:B1", etc..
    * <mark style="color:red;">**"dimension"**</mark>**&#x20;(**[**Dimension**](#dimension)**, optional):** Reading dimension. May be [**Dimension**](#dimension)**.**[**ROWS**](#rows) or [**Dimension**](#dimension)**.**[**COLUMNS**](#columns). Defaults to[ **Dimension**](#dimension)**.**[**ROWS**](#rows).
    * <mark style="color:red;">**"table"**</mark>**&#x20;(List\[List\[Any]]):** Values to add to spreadsheet.

#### Raises:

* **Exception:** If unable to update spreadsheet.

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"spreadsheet"**</mark> **(Dict\[str, Any]):** Updated spreadsheet;

***

***

***

## <mark style="color:green;">GoogleSpreadsheetsAppend</mark>

Write to spreadsheet. Subclass of [**GoogleSheetsAction**](#googlespreadsheetsaction). Type of \
[**GoogleSheetsAction**](#googlespreadsheetsaction)**\[Dict\[str, Any], Dict\[str, Any]]**.

***

### <mark style="color:blue;">execute</mark>

#### Arguments:

* <mark style="color:orange;">**input\_data**</mark>**&#x20;(Dict\[str, Any]):** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"spreadsheet\_id"**</mark> **(str):** Spreadsheet ID (can be found in url: <https://docs.google.com/spreadsheets/d/>*<mark style="color:purple;">**spreadsheet\_id**</mark>*/edit#gid=0);
  * <mark style="color:red;">**"cells\_range"**</mark>**&#x20;(str):** Range of cells provided in A1 notation. Examples: "B2:C2", "A1", "Sheet1", "Sheet1!A1:B1", etc..
  * <mark style="color:red;">**"value\_input\_option"**</mark>**&#x20;(**[**InputOption**](#inputoption)**, optional):** Input option can be: [**InputOption**](#inputoption)**.**[**USER\_ENTERED**](#user_entered) - All inputs treated as input from the user (enabling formatting and formulas), or[ **InputOption**](#inputoption)**.**[**RAW**](#raw) - all inputs as is. Defaults to [**InputOption**](#inputoption)**.**[**USER\_ENTERED**](#user_entered).
  * <mark style="color:red;">**"insert\_data\_option"**</mark> **(**[**InsertDataOption**](#insertdataoption)**, optional):** Isert data option can be [**InsertDataOption**](#insertdataoption)**.**[**OVERWRITE**](#overwrite) - will overwrite anything after table, or [**InsertDataOption**](#insertdataoption)**.**[**INSERT\_ROWS**](#insert_rows) - will insert new rows. Defaults to [**InsertDataOption**](#insertdataoption)**.**[**OVERWRITE**](#overwrite).
  * <mark style="color:red;">**"dimension"**</mark>**&#x20;(**[**Dimension**](#dimension)**, optional):** Reading dimension. May be [**Dimension**](#dimension)**.**[**ROWS**](#rows) or [**Dimension**](#dimension)**.**[**COLUMNS**](#columns). Defaults to[ **Dimension**](#dimension)**.**[**ROWS**](#rows).
  * <mark style="color:red;">**"table"**</mark>**&#x20;(List\[List\[Any]]):** Values to add to spreadsheet.

#### Raises:

* **Exception:** If unable to update spreadsheet.

#### Returns:

* **Dict\[str, Any]:** \
  Expected keys:&#x20;
  * <mark style="color:red;">**"spreadsheet"**</mark> **(Dict\[str, Any]):** Updated spreadsheet;

***

***

***

## <mark style="color:green;">GoogleSheetsClientConfig</mark>

Google Sheets default configuration. Subclass of [**GoogleCloudClientConfig**](/apis/googlecloudclient.md#googlecloudclientconfig).

***

### <mark style="color:blue;">\_\_init\_\_</mark>

#### Arguments:

* <mark style="color:orange;">**scopes**</mark>**&#x20;(List\[str]):** Access scopes. Defaults to \["<https://www.googleapis.com/auth/spreadsheets>"] **(Read and write acess to all spreadsheets).**
* <mark style="color:orange;">**service**</mark>**&#x20;(str):** Service name. Defaults to "sheets" (Google Spreadsheets service).
* <mark style="color:orange;">**version**</mark>**&#x20;(str):** API version. Defaults to "v4".

***

***

***

## <mark style="color:green;">Dimension</mark>

Specify major dimension(i.e. what outer list represents)

***

### <mark style="color:blue;">ROWS</mark>

***

### <mark style="color:blue;">COLUMNS</mark>

***

***

***

## <mark style="color:green;">InputOption</mark>

Specify how input data should be formatted

***

### <mark style="color:blue;">RAW</mark>

Inputs as is

***

### <mark style="color:blue;">USER\_ENTERED</mark>

All inputs treated as input from the user (enabling formatting and formulas)

***

***

***

## <mark style="color:green;">InsertDataOption</mark>

How data should be append to table

***

### <mark style="color:blue;">INSERT\_ROWS</mark>

Insert new rows

***

### <mark style="color:blue;">OVERWRITE</mark>

Overwrite anything after table

***

***
