Google Sheets

The Google Sheets action allows you to interact with Google Sheets. It supports creating new spreadsheets, appending data to existing sheets, and exporting spreadsheets in various formats. Mechanic interacts with Google Sheets via the Google Sheets API, using OAuth2 for authentication.

Due to Google security restrictions, Mechanic can only access spreadsheets that were created through Mechanic itself. To work with Google Sheets:

  • First create a spreadsheet using the "create_spreadsheet" operation

  • Store the returned spreadsheet ID for later use

  • Then use operations like "append_rows" on this spreadsheet

See this great example in the task library.

Options

Option
Type
Description

account

string

Required: the Google account email address to authenticate with

operation

string

Required: the operation to perform. One of: "append_rows", "create_spreadsheet", "export_spreadsheet"

spreadsheet_id

string

Required: for append_rows and export_spreadsheet; the ID of the target spreadsheet

title

string

Required: for create_spreadsheet; the title for the new spreadsheet

rows

array

Required: for append_rows and optional for create_spreadsheet; array of arrays containing the data to write

sheet_name

string

Optional: for append_rows; defaults to "Sheet1"

file_type

string

Optional: for export_spreadsheet; the format to export. One of: "xlsx" (default), "csv", "pdf", "html", "ods", "tsv"

folder_path

string

Optional: for create_spreadsheet; the folder path where the spreadsheet should be created (e.g., "reports/2024/monthly")

Operations

append_rows

Adds new rows to an existing spreadsheet.

Required Options

  • account

  • spreadsheet_id

  • rows

Optional Options

  • sheet_name (defaults to "Sheet1")

create_spreadsheet

Creates a new spreadsheet, optionally with initial data.

Required Options

  • account

  • title

Optional Options

  • folder_path (path where spreadsheet should be created)

  • rows (initial data to populate the spreadsheet)

export_spreadsheet

Exports a spreadsheet in various formats.

Required Options

  • account

  • spreadsheet_id

Optional Options

  • file_type

    • xlsx (default)

    • csv

    • pdf

    • html

    • ods

    • tsv

Authentication

This action requires connecting a Google account with the appropriate permissions. To connect an account:

  1. Go to the Settings screen

  2. Click Authentication

  3. Follow the Google account connection flow from the Google tab

File Access

The action can only access spreadsheets it creates, no other spreadsheets in your drive.

Folder Support

When creating spreadsheets, you can specify a folder path to organize your files:

  • Use forward slashes to separate folder names (e.g., "reports/2024/monthly")

  • Folders will be created if they don't exist

  • Can only access folders created by this integration

  • Invalid characters not allowed: < > : " / \ | ? *

Folder Path Examples

Examples

Append Rows to Existing Google Sheet

Create New Google Sheet

Export Google Sheet

Dynamic Data Example

Create Google Sheet in a Folder

Read Data From Google Sheet

Action Responses

The action returns different responses based on the operation performed:

append_rows Response

Example:

create_spreadsheet Response

Example:

create_spreadsheet Response with Folder

Example:

export_spreadsheet Response

Example:

Last updated

Was this helpful?