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

To use these operators, you must do a few things:

Create spreadsheet

To create new spreadsheet you can use the GoogleSheetsCreateSpreadsheetOperator.


create_spreadsheet = GoogleSheetsCreateSpreadsheetOperator(
    task_id="create_spreadsheet", spreadsheet=SPREADSHEET, gcp_conn_id=CONNECTION_ID

You can use Jinja templating with spreadsheet, impersonation_chain.

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


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

Was this entry helpful?