Google Sheets Operators

The latest version of the Sheets API lets developers programmatically:

  • Read and write data

  • Format text and numbers

  • Build pivot tables

  • Enforce cell validation

  • Set frozen rows

  • Adjust column sizes

  • Apply formulas

  • Create charts… and more!

For more information check official documentation.

Prerequisite Tasks

Create spreadsheet

To create new spreadsheet you can use the GoogleSheetsCreateSpreadsheetOperator.

tests/system/providers/google/cloud/gcs/example_sheets.py[source]

create_spreadsheet = GoogleSheetsCreateSpreadsheetOperator(
    task_id="create_spreadsheet", spreadsheet=SPREADSHEET
)

You can use Jinja templating with spreadsheet, impersonation_chain.

To get the URL of newly created spreadsheet use XCom value:

tests/system/providers/google/cloud/gcs/example_sheets.py[source]

print_spreadsheet_url = BashOperator(
    task_id="print_spreadsheet_url",
    bash_command=f"echo {XComArg(create_spreadsheet, key='spreadsheet_url')}",
)

Was this entry helpful?