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.
Create spreadsheet¶
To create new spreadsheet you can use the
GoogleSheetsCreateSpreadsheetOperator
.
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:
print_spreadsheet_url = BashOperator(
task_id="print_spreadsheet_url",
bash_command="echo {{ task_instance.xcom_pull('create_spreadsheet', key='spreadsheet_url') }}",
)