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
如需了解详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-22。
[null,null,["最后更新时间 (UTC):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)."]]