# Google Sheets Block

### Granting Access to the Spreadsheet

Before using this integration, you need to give access to the GoLess service. You can do this in two ways:

1. Share the spreadsheet publicly, but note that GoLess will only have read access.
2. Share the spreadsheet with the GoLess service account by clicking the share button on the top right of the spreadsheet and entering <mark style="color:orange;">`goless@goless.iam.gserviceaccount.com`</mark>.\\

<figure><img src="https://742850480-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmtnl2J19CnNVA5fLFAPs%2Fuploads%2Fgit-blob-0c10f1a5e716dde5cc6c3f73939967a9e08f0502%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Spreadsheet ID

The Spreadsheet ID is a string of letters, numbers, hyphens, or underscores. You can find it in the Google Sheets URL.

`https://docs.google.com/spreadsheets/d/`<mark style="color:green;">`1CyccvSsq0VdujNThPKr3l8ipLQfQo9KuzTpJxpwTPyg`</mark>`/edit#gid=0`

<figure><img src="https://742850480-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fmtnl2J19CnNVA5fLFAPs%2Fuploads%2Fgit-blob-88ab76cd89532cae8daf95867b12840e339840c0%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Cell Range

The cell range is the range of the cells that you want to get or update. You can define the range using either the [A1 notation](https://developers.google.com/sheets/api/guides/concepts#expandable-1) like `Sheet1!A1:B2` or [R1C1 notation](https://developers.google.com/sheets/api/guides/concepts#expandable-2) like `Sheet1!R1C1:R2C2`.

### Reading Spreadsheet Values

You can get the values of the cells in the spreadsheet.

* **Reference key** The key for identifying the Google Sheets data.
* **Use the first row as keys** Use the first row of the spreadsheet as the object key. For example, if you have a spreadsheet like this:

| name | age |
| ---- | --- |
| foo  | 22  |
| bar  | 23  |

```json
// option disabled
[["name", "age"], ["foo", 22], ["bar", 23]]

// option enabled
[{ "name": "foo", "age": 22 }, { "name": "bar", "age": 23 }]
```

#### Accessing Spreadsheet Data

To access the spreadsheet values from an input of a block, you can use expressions like `{{ googleSheets.referenceKey.path }}` syntax.

Read more: [Expressions](https://docs.goless.com/workflow/expressions#writing-expression)

### Updating Spreadsheet Values

You can update the values of the cells in the spreadsheet.

* **Value input option** Determines how input data should be interpreted, defaulting to `RAW`.

| Value          | Description                                                                                                                                                                                                                                            |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `RAW`          | The values the user has entered will not be parsed and will be stored as-is                                                                                                                                                                            |
| `USER_ENTERED` | The values will be parsed as if the user typed them into the UI. Numbers will stay as numbers, but strings may be converted to numbers, dates, etc. following the same rules that are applied when entering text into a cell via the Google Sheets UI. |

Read more on the [Google developer page](https://developers.google.com/sheets/api/reference/rest/v4/ValueInputOption)

* **Data source** The source of the data for updating the spreadsheet defaults to a [table](https://docs.goless.com/workflow/workflow-table). When using the custom option, the input data must be an array of arrays with valid JSON syntax.

**Example**

```json
[["name", "age"], ["foo", 22], ["bar", 23, "text"]]
```

* **Use keys as the first row** Use the columns as the first row on the spreadsheet.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.goless.com/blocks/onlineservices/google-sheets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
