Skip to content

Google Sheets — Read sheet

Type: googlesheets-read-sheet  ·  Package: Google Sheets Activities v1.0.5  ·  Output: DataTable

Reads all the data in a sheet and always returns it as a DataTable. It is the most common read: bring the whole content in to process it row by row, filter it or hand it to another activity.

Reads the area with data of the given sheet (the first one if sheet is empty), from A1 to the last row and column with content, in a single call to Google.

  • With has-headers = true, the first row provides the column names and the following rows are the data. Cells in a row longer than the header row are dropped.
  • With has-headers = false (default), columns are named Column1, Column2, … up to the longest row, and the first row is data too.
  • Every cell arrives as text as displayed in the sheet; empty cells as "". A formula is read as its result.

None.

ParameterTypeDefaultDescription
sessionZoanGoogleSheetsSession—Session from Google Sheets — Open. Inside Open’s body it is inherited and you can leave it empty.
sheetstring—Sheet name. If empty, reads the first sheet.
has-headersboolfalseTreat the first row as column names. If false, columns are named Column1, Column2, …

Always a DataTable with text columns. If the sheet is empty, returns an empty DataTable (no columns or rows), not an error: check it with rowCount(table) == 0. With has-headers = true and only the header row, returns the columns with no rows.

MessageCause and fix
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.
The spreadsheet has no sheets to read.sheet is empty and the document has no sheets visible to the API.
A column named '…' already belongs to this DataTable.With has-headers = true, two headers have the same text. Rename one in the sheet or read with has-headers = false.
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.
Google Sheets — Read sheet session = book sheet = "Orders" has-headers = true → output: orders
For Each items = orders itemVariable = row
└─ activities:
Log message = str(row["Customer"]) + " — " + num(row["Total"])