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 |
系統會插入新資料的資料列。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-03-22 (世界標準時間)。
[null,null,["上次更新時間: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. |"]]