Method: spreadsheets.values.batchUpdate
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
HTTP 要求
POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values:batchUpdate
這個網址使用 gRPC 轉碼語法。
路徑參數
參數 |
spreadsheetId |
string
要更新的工作表 ID。
|
要求主體
要求主體的資料會採用以下結構:
欄位 |
valueInputOption |
enum (ValueInputOption )
系統如何解讀輸入資料。
|
data[] |
object (ValueRange )
要套用至試算表的新值。
|
includeValuesInResponse |
boolean
判斷更新回應是否應包含已更新的儲存格值。根據預設,回應不會包含更新後的值。每個 BatchUpdateValuesResponse.responses 中的 updatedData 欄位都包含更新後的值。如果要寫入的範圍大於實際寫入的範圍,回應會包含要求範圍中的所有值 (不含結尾空白資料列和資料欄)。
|
responseValueRenderOption |
enum (ValueRenderOption )
決定回應中的值應如何顯示。預設轉譯選項為 FORMATTED_VALUE 。
|
responseDateTimeRenderOption |
enum (DateTimeRenderOption )
決定回應中日期、時間和時間長度的顯示方式。如果 responseValueRenderOption 為 FORMATTED_VALUE ,系統會忽略這項屬性。預設的 dateTime 轉譯選項為 SERIAL_NUMBER 。
|
回應主體
更新試算表中值的範圍時的回應。
如果成功,回應主體會含有以下結構的資料:
JSON 表示法 |
{
"spreadsheetId": string,
"totalUpdatedRows": integer,
"totalUpdatedColumns": integer,
"totalUpdatedCells": integer,
"totalUpdatedSheets": integer,
"responses": [
{
object (UpdateValuesResponse )
}
]
} |
欄位 |
spreadsheetId |
string
套用更新的試算表。
|
totalUpdatedRows |
integer
資料列中至少有一個儲存格更新的資料列總數。
|
totalUpdatedColumns |
integer
至少有一個儲存格更新的欄總數。
|
totalUpdatedCells |
integer
更新的儲存格總數。
|
totalUpdatedSheets |
integer
試算表中至少有一個儲存格更新的試算表總數。
|
responses[] |
object (UpdateValuesResponse )
每個要求範圍一個 UpdateValuesResponse,且順序與要求出現的順序相同。
|
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/spreadsheets
詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-03-22 (世界標準時間)。
[null,null,["上次更新時間:2025-03-22 (世界標準時間)。"],[],[],null,["# Method: spreadsheets.values.batchUpdate\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n - [JSON representation](#body.request_body.SCHEMA_REPRESENTATION)\n- [Response body](#body.response_body)\n - [JSON representation](#body.BatchUpdateValuesResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nSets values in one or more ranges of a spreadsheet. The caller must specify the spreadsheet ID, a [valueInputOption](/workspace/sheets/api/reference/rest/v4/ValueInputOption), and one or more [ValueRanges](/workspace/sheets/api/reference/rest/v4/spreadsheets.values#ValueRange).\n\n### HTTP request\n\n`POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values:batchUpdate`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|-----------------|-----------------------------------------------|\n| `spreadsheetId` | `string` The ID of the spreadsheet to update. |\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation |\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"valueInputOption\": enum (/workspace/sheets/api/reference/rest/v4/ValueInputOption), \"data\": [ { object (/workspace/sheets/api/reference/rest/v4/spreadsheets.values#ValueRange) } ], \"includeValuesInResponse\": boolean, \"responseValueRenderOption\": enum (/workspace/sheets/api/reference/rest/v4/ValueRenderOption), \"responseDateTimeRenderOption\": enum (/workspace/sheets/api/reference/rest/v4/DateTimeRenderOption) } ``` |\n\n| Fields ||\n|--------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `valueInputOption` | `enum (`[ValueInputOption](/workspace/sheets/api/reference/rest/v4/ValueInputOption)`)` How the input data should be interpreted. |\n| `data[]` | `object (`[ValueRange](/workspace/sheets/api/reference/rest/v4/spreadsheets.values#ValueRange)`)` The new values to apply to the spreadsheet. |\n| `includeValuesInResponse` | `boolean` Determines if the update response should include the values of the cells that were updated. By default, responses do not include the updated values. The `updatedData` field within each of the [BatchUpdateValuesResponse.responses](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/batchUpdate#body.BatchUpdateValuesResponse.FIELDS.responses) contains the updated values. If the range to write was larger than the range actually written, the response includes all values in the requested range (excluding trailing empty rows and columns). |\n| `responseValueRenderOption` | `enum (`[ValueRenderOption](/workspace/sheets/api/reference/rest/v4/ValueRenderOption)`)` Determines how values in the response should be rendered. The default render option is [FORMATTED_VALUE](/workspace/sheets/api/reference/rest/v4/ValueRenderOption). |\n| `responseDateTimeRenderOption` | `enum (`[DateTimeRenderOption](/workspace/sheets/api/reference/rest/v4/DateTimeRenderOption)`)` Determines how dates, times, and durations in the response should be rendered. This is ignored if [responseValueRenderOption](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/batchUpdate#body.request_body.FIELDS.response_value_render_option) is [FORMATTED_VALUE](/workspace/sheets/api/reference/rest/v4/ValueRenderOption). The default dateTime render option is [SERIAL_NUMBER](/workspace/sheets/api/reference/rest/v4/DateTimeRenderOption). |\n\n### Response body\n\nThe response when updating a range of values in a spreadsheet.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"spreadsheetId\": string, \"totalUpdatedRows\": integer, \"totalUpdatedColumns\": integer, \"totalUpdatedCells\": integer, \"totalUpdatedSheets\": integer, \"responses\": [ { object (/workspace/sheets/api/reference/rest/v4/UpdateValuesResponse) } ] } ``` |\n\n| Fields ||\n|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `spreadsheetId` | `string` The spreadsheet the updates were applied to. |\n| `totalUpdatedRows` | `integer` The total number of rows where at least one cell in the row was updated. |\n| `totalUpdatedColumns` | `integer` The total number of columns where at least one cell in the column was updated. |\n| `totalUpdatedCells` | `integer` The total number of cells updated. |\n| `totalUpdatedSheets` | `integer` The total number of sheets where at least one cell in the sheet was updated. |\n| `responses[]` | `object (`[UpdateValuesResponse](/workspace/sheets/api/reference/rest/v4/UpdateValuesResponse)`)` One UpdateValuesResponse per requested range, in the same order as the requests appeared. |\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/drive`\n- `https://www.googleapis.com/auth/drive.file`\n- `https://www.googleapis.com/auth/spreadsheets`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]