Method: spreadsheets.values.append
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
将值附加到电子表格。输入范围用于搜索现有数据并在该范围内查找“表”。值将附加到表格的下一行,从表格的第一个列开始。如需详细了解如何检测表格并附加数据,请参阅指南和示例代码。
调用方必须指定电子表格 ID、范围和 valueInputOption
。valueInputOption
仅控制输入数据将以何种方式添加到工作表(按列或按行),不会影响数据开始写入的单元格。
HTTP 请求
POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}:append
网址采用 gRPC 转码语法。
路径参数
参数 |
spreadsheetId |
string
要更新的电子表格的 ID。
|
range |
string
用于搜索数据逻辑表的范围的 A1 表示法。值会附加到表格的最后一行后面。
|
查询参数
参数 |
valueInputOption |
enum (ValueInputOption )
应如何解读输入数据。
|
insertDataOption |
enum (InsertDataOption )
输入数据的插入方式。
|
includeValuesInResponse |
boolean
确定更新响应是否应包含附加的单元格的值。默认情况下,响应不包含更新后的值。
|
responseValueRenderOption |
enum (ValueRenderOption )
确定应如何呈现响应中的值。默认渲染选项为 FORMATTED_VALUE 。
|
responseDateTimeRenderOption |
enum (DateTimeRenderOption )
确定响应中日期、时间和时长的呈现方式。如果 responseValueRenderOption 为 FORMATTED_VALUE ,系统会忽略此值。默认的 dateTime 呈现选项为 SERIAL_NUMBER 。
|
请求正文
请求正文包含一个 ValueRange
实例。
响应正文
更新电子表格中一组值时的响应。
如果成功,响应正文将包含结构如下的数据:
JSON 表示法 |
{
"spreadsheetId": string,
"tableRange": string,
"updates": {
object (UpdateValuesResponse )
}
} |
字段 |
spreadsheetId |
string
应用了更新的电子表格。
|
tableRange |
string
要附加值的表格的范围(采用 A1 表示法,在附加值之前)。如果未找到任何表,则为空。
|
updates |
object (UpdateValuesResponse )
已应用的更新的相关信息。
|
授权范围
需要以下 OAuth 范围之一:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/spreadsheets
如需了解详情,请参阅授权指南。
InsertDataOption
枚举 |
OVERWRITE |
新数据会覆盖其写入区域中的现有数据。(注意:向工作表的末尾添加数据仍会插入新行或新列,以便写入数据。) |
INSERT_ROWS |
系统会为新数据插入行。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-22。
[null,null,["最后更新时间 (UTC):2025-03-22。"],[],[],null,["# Method: spreadsheets.values.append\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.AppendValuesResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [InsertDataOption](#InsertDataOption)\n- [Try it!](#try-it)\n\nAppends values to a spreadsheet. The input range is used to search for existing data and find a \"table\" within that range. Values will be appended to the next row of the table, starting with the first column of the table. See the [guide](https://developers.google.com/workspace/sheets/api/guides/values#appending_values) and [sample code](https://developers.google.com/workspace/sheets/api/samples/writing#append_values) for specific details of how tables are detected and data is appended.\n\nThe caller must specify the spreadsheet ID, range, and a [valueInputOption](/workspace/sheets/api/reference/rest/v4/ValueInputOption). The `valueInputOption` only controls how the input data will be added to the sheet (column-wise or row-wise), it does not influence what cell the data starts being written to.\n\n### HTTP request\n\n`POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}:append`\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| `range` | `string` The [A1 notation](https://developers.google.com/workspace/sheets/api/guides/concepts#cell) of a range to search for a logical table of data. Values are appended after the last row of the table. |\n\n### Query parameters\n\n| Parameters ||\n|--------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `valueInputOption` | `enum (`[ValueInputOption](/workspace/sheets/api/reference/rest/v4/ValueInputOption)`)` How the input data should be interpreted. |\n| `insertDataOption` | `enum (`[InsertDataOption](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/append#InsertDataOption)`)` How the input data should be inserted. |\n| `includeValuesInResponse` | `boolean` Determines if the update response should include the values of the cells that were appended. By default, responses do not include the updated values. |\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/append#body.QUERY_PARAMETERS.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### Request body\n\nThe request body contains an instance of [ValueRange](/workspace/sheets/api/reference/rest/v4/spreadsheets.values#ValueRange).\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, \"tableRange\": string, \"updates\": { object (/workspace/sheets/api/reference/rest/v4/UpdateValuesResponse) } } ``` |\n\n| Fields ||\n|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `spreadsheetId` | `string` The spreadsheet the updates were applied to. |\n| `tableRange` | `string` The range (in A1 notation) of the table that values are being appended to (before the values were appended). Empty if no table was found. |\n| `updates` | `object (`[UpdateValuesResponse](/workspace/sheets/api/reference/rest/v4/UpdateValuesResponse)`)` Information about the updates that were applied. |\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).\n\nInsertDataOption\n----------------\n\nDetermines how existing data is changed when new data is input.\n\n| Enums ||\n|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `OVERWRITE` | The new data overwrites existing data in the areas it is written. (Note: adding data to the end of the sheet will still insert new rows or columns so the data can be written.) |\n| `INSERT_ROWS` | Rows are inserted for the new data. |"]]