Method: spreadsheets.values.batchUpdate
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Define valores em um ou mais intervalos de uma planilha. O autor da chamada precisa especificar o ID da planilha, um valueInputOption
e um ou mais ValueRanges
.
Solicitação HTTP
POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values:batchUpdate
O URL usa a sintaxe de transcodificação gRPC.
Parâmetros de caminho
Parâmetros |
spreadsheetId |
string
O ID da planilha a ser atualizada.
|
Corpo da solicitação
O corpo da solicitação contém dados com a seguinte estrutura:
Campos |
valueInputOption |
enum (ValueInputOption )
Como os dados de entrada devem ser interpretados.
|
data[] |
object (ValueRange )
Os novos valores a serem aplicados à planilha.
|
includeValuesInResponse |
boolean
Determina se a resposta de atualização precisa incluir os valores das células que foram atualizadas. Por padrão, as respostas não incluem os valores atualizados. O campo updatedData em cada BatchUpdateValuesResponse.responses contém os valores atualizados. Se o intervalo a ser gravado for maior do que o intervalo gravado, a resposta vai incluir todos os valores no intervalo solicitado (exceto linhas e colunas vazias finais).
|
responseValueRenderOption |
enum (ValueRenderOption )
Determina como os valores na resposta devem ser renderizados. A opção de renderização padrão é FORMATTED_VALUE .
|
responseDateTimeRenderOption |
enum (DateTimeRenderOption )
Determina como as datas, os horários e as durações na resposta devem ser renderizados. Isso será ignorado se responseValueRenderOption for FORMATTED_VALUE . A opção padrão de renderização de data/hora é SERIAL_NUMBER .
|
Corpo da resposta
A resposta ao atualizar um intervalo de valores em uma planilha.
Se bem-sucedido, o corpo da resposta incluirá dados com a estrutura a seguir:
Representação JSON |
{
"spreadsheetId": string,
"totalUpdatedRows": integer,
"totalUpdatedColumns": integer,
"totalUpdatedCells": integer,
"totalUpdatedSheets": integer,
"responses": [
{
object (UpdateValuesResponse )
}
]
} |
Campos |
spreadsheetId |
string
A planilha em que as atualizações foram aplicadas.
|
totalUpdatedRows |
integer
O número total de linhas em que pelo menos uma célula foi atualizada.
|
totalUpdatedColumns |
integer
O número total de colunas em que pelo menos uma célula foi atualizada.
|
totalUpdatedCells |
integer
O número total de células atualizadas.
|
totalUpdatedSheets |
integer
O número total de planilhas em que pelo menos uma célula foi atualizada.
|
responses[] |
object (UpdateValuesResponse )
Uma UpdateValuesResponse por intervalo solicitado, na mesma ordem em que as solicitações apareceram.
|
Escopos de autorização
Requer um dos seguintes escopos do OAuth:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/spreadsheets
Para mais informações, consulte o guia de autorização.
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2025-03-22 UTC.
[null,null,["Última atualização 2025-03-22 UTC."],[],[],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)."]]