Google Sheets — Read range
Google Sheets — Read range
Section titled “Google Sheets — Read range”Type: googlesheets-read-range · Package: Google Sheets Activities v1.0.5 · Output: DataTable
Reads a specific range of cells into a DataTable. Same as Read sheet, but limited to a range in A1 notation: handy when you only need part of the sheet, or when the data does not start at A1.
How it works
Section titled “How it works”Reads range in the sheet sheet (the first one if empty). Google returns from the first cell of the range to the last row and column with data inside it, so A:E does not bring back thousands of empty rows.
- With
has-headers = true, the first row of the range provides the column names. - With
has-headers = false(default), columns are namedColumn1,Column2, … - Every cell arrives as text as displayed in the sheet; empty cells as
"".
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
range | string | — | Range in A1 notation: A1:E10, A:E, 1:100. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanGoogleSheetsSession | — | Session from Google Sheets — Open. Inside Open’s body it is inherited and you can leave it empty. |
sheet | string | — | Sheet name. If empty, the first sheet is used. |
has-headers | bool | false | Use the first row of the range as column names; otherwise Column1, Column2, … |
Output
Section titled “Output”Always a DataTable with text columns. If the range is empty, returns an empty DataTable (no columns or rows).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'range' is required. | range is empty or its expression returned null. |
No Google Sheets session available. Provide 'session' from a googlesheets-open activity, or place this activity inside the Open activity's body … | The activity is outside Open’s body and received no session. Move it inside the body or pass the saved session. |
A column named '…' already belongs to this DataTable. | With has-headers = true, two headers in the range have the same text. |
The service sheets has thrown an exception. HttpStatusCode is … | Google rejected the call: missing sheet or range, no access, expired token or quota exceeded. See Google API errors. |
Example
Section titled “Example”Google Sheets — Read range session = book sheet = "Summary" range = "B3:E50" has-headers = true → output: dataLog message = "Rows read: " + rowCount(data)Related activities
Section titled “Related activities”- Read sheet — read the whole sheet.
- Used range — find the range with data before reading.
- Read cell — read one cell.