Workflows connector that defines the built-in function used to access Google Sheets from within a workflow.

## Explore further


For detailed documentation that includes this code sample, see the following:

- [Google Sheets API Connector Overview](https://docs.cloud.google.com/workflows/docs/reference/googleapis/sheets/Overview)

## Code sample

### YAML

    # This workflow demonstrates how to use the Google Sheets connector:
    # Create, update, get, and delete a Google Sheets spreadsheet
    # Expected output: "SUCCESS"
    - init:
        assign:
          - createRange: "A20"  # example range
          - getRange: "A1:B4"  # example range
          - row:
              values:
                - {"userEnteredFormat": {"backgroundColor": {"red": 0, "green":1, "blue":0, "alpha":1}}}
          - start1:
              sheetId: 0
              rowIndex: 2
              columnIndex: 0
          - request1:
              rows:
                - ${row}
              fields: userEnteredFormat.backgroundColor
              start: ${start1}
          - driveScope: https://www.googleapis.com/auth/drive
    - create_spreadsheet:
        call: googleapis.sheets.v4.spreadsheets.create
        args:
          body:
          connector_params:
            scopes: ${driveScope}
        result: resp
    - assign_sheet_id:
        assign:
          - sheetId: ${resp.spreadsheetId}
    - update_spreadsheet:
        call: googleapis.sheets.v4.spreadsheets.values.update
        args:
          spreadsheetId: ${sheetId}
          range: ${createRange}
          valueInputOption: RAW
          includeValuesInResponse:
          body:
            values:
              - ["text to update"]
    - batch_update:
        call: googleapis.sheets.v4.spreadsheets.batchUpdate
        args:
          spreadsheetId: ${sheetId}
          body:
            requests:
              - updateCells: ${request1}
            includeSpreadsheetInResponse: true
          connector_params:
            scopes: ${driveScope}
    - get_from_sheet:
        call: googleapis.sheets.v4.spreadsheets.get
        args:
          spreadsheetId: ${sheetId}
          ranges:
            - ${getRange}
          includeGridData: false
          connector_params:
            scopes: ${driveScope}
    - delete_sheet:
        call: http.delete
        args:
          url: ${"https://www.googleapis.com/drive/v2/files/" + sheetId}
          auth:
            type: OAuth2
            scopes: ${driveScope}
    - return_step:
        return: SUCCESS

## What's next


To search and filter code samples for other Google Cloud products, see the
[Google Cloud sample browser](https://docs.cloud.google.com/docs/samples?product=workflows).