Google Sheets용 커넥터

워크플로 내에서 Google Sheets에 액세스하는 데 사용되는 기본 제공 함수를 정의하는 Workflows 커넥터입니다.

더 살펴보기

이 코드 샘플이 포함된 자세한 문서는 다음을 참조하세요.

코드 샘플

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

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저를 참조하세요.