Method: spreadsheets.batchUpdate

為試算表套用一或多筆更新,

每個 request 必須先經過驗證才能套用。如果有任何要求無效,整個請求就會失敗,系統不會套用任何要求。

某些要求會透過 replies 提供一些資訊,讓您瞭解應如何套用。這些回覆會沿用要求。舉例來說,假設您套用了 4 項更新,而第 3 項回應有 1 則回覆,則回覆會有 2 則空白回覆、實際回覆及另一個空白的回覆。

由於試算表具有協作性質,因此無法保證試算表在完成後會完整反映您變更的內容,但無法保證系統一定會完整套用這項要求中的更新。協作者可能有所變動。如果沒有協作者,試算表應會反映您所做的變更。

HTTP 要求

POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}:batchUpdate

這個網址使用 gRPC 轉碼語法。

路徑參數

參數
spreadsheetId

string

要套用更新的試算表。

要求主體

要求主體的資料會採用以下結構:

JSON 表示法
{
  "requests": [
    {
      object (Request)
    }
  ],
  "includeSpreadsheetInResponse": boolean,
  "responseRanges": [
    string
  ],
  "responseIncludeGridData": boolean
}
欄位
requests[]

object (Request)

要套用至試算表的更新清單。會按照指定的順序套用要求。如果有任何要求無效,系統就不會套用任何要求。

includeSpreadsheetInResponse

boolean

決定更新回應是否應包含試算表資源。

responseRanges[]

string

限制回應試算表包含的範圍。只有在 includeSpreadsheetInResponse 為「true」時,才有意義。

responseIncludeGridData

boolean

如果應該傳回格線資料,則為 True。只有在 includeSpreadsheetInResponse 為「true」時,才有意義。如果在要求中設定欄位遮罩,系統會忽略這個參數。

回應主體

批次更新試算表回覆。

如果成功,回應主體即會包含具有以下結構的資料:

JSON 表示法
{
  "spreadsheetId": string,
  "replies": [
    {
      object (Response)
    }
  ],
  "updatedSpreadsheet": {
    object (Spreadsheet)
  }
}
欄位
spreadsheetId

string

套用更新的試算表。

replies[]

object (Response)

更新內容的回覆。這張圖表包含 1:1 的更新內容,但某些要求中的回覆可能是空的。

updatedSpreadsheet

object (Spreadsheet)

套用更新後的試算表。只有在 BatchUpdateSpreadsheetRequest.include_spreadsheet_in_responsetrue 時,這才會設定。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/drive
  • https://www.googleapis.com/auth/drive.file
  • https://www.googleapis.com/auth/spreadsheets

詳情請參閱授權指南