Method: spreadsheets.values.append
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ต่อท้ายค่าในสเปรดชีต ระบบจะใช้ช่วงอินพุตเพื่อค้นหาข้อมูลที่มีอยู่และค้นหา "ตาราง" ภายในช่วงนั้น ระบบจะเพิ่มค่าต่อท้ายแถวถัดไปของตาราง โดยเริ่มจากคอลัมน์แรกของตาราง ดูรายละเอียดที่เฉพาะเจาะจงเกี่ยวกับวิธีตรวจหาตารางและเพิ่มข้อมูลต่อท้ายได้ที่คู่มือและโค้ดตัวอย่าง
ผู้เรียกต้องระบุรหัสสเปรดชีต ช่วง และ valueInputOption
valueInputOption
จะควบคุมเฉพาะวิธีเพิ่มข้อมูลอินพุตลงในชีต (ตามคอลัมน์หรือตามแถว) เท่านั้น จะไม่มีผลต่อเซลล์ที่ระบบจะเริ่มเขียนข้อมูล
คำขอ HTTP
POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}:append
URL ใช้ไวยากรณ์การแปลง gRPC
พารามิเตอร์เส้นทาง
พารามิเตอร์ |
spreadsheetId |
string
รหัสของสเปรดชีตที่จะอัปเดต
|
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
กำหนดวิธีเปลี่ยนแปลงข้อมูลที่มีอยู่เมื่อมีการป้อนข้อมูลใหม่
Enum |
OVERWRITE |
ข้อมูลใหม่จะเขียนทับข้อมูลที่มีอยู่ในพื้นที่ที่เขียน (หมายเหตุ: การเพิ่มข้อมูลลงท้ายชีตจะยังคงแทรกแถวหรือคอลัมน์ใหม่เพื่อให้เขียนข้อมูลได้) |
INSERT_ROWS |
ระบบจะแทรกแถวสําหรับข้อมูลใหม่ |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-03-22 UTC
[null,null,["อัปเดตล่าสุด 2025-03-22 UTC"],[],[],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. |"]]