ภาพรวมของ Google Sheets API
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Google Sheets API เป็นอินเทอร์เฟซ RESTful ที่ช่วยให้คุณอ่านและแก้ไขข้อมูลของสเปรดชีตได้ Sheets API ช่วยให้คุณทำสิ่งต่อไปนี้ได้
- สร้างสเปรดชีต
- อ่านและเขียนค่าในเซลล์ของสเปรดชีต
- อัปเดตการจัดรูปแบบสเปรดชีต
- จัดการชีตที่เชื่อมต่อ
ต่อไปนี้คือรายการคำศัพท์ที่ใช้กันโดยทั่วไปในชีต API
- สเปรดชีต
ออบเจ็กต์หลักใน Google ชีต โดยอาจมี Sheets
หลายรายการ ซึ่งแต่ละรายการ
จะมีข้อมูลที่มีโครงสร้างอยู่ใน Cells
แหล่งข้อมูล
spreadsheets
แสดงถึงสเปรดชีต โดยมีspreadsheetId
ค่าที่ไม่ซ้ำกัน
- รหัสสเปรดชีต
- ตัวระบุที่ไม่ซ้ำกันสำหรับสเปรดชีต โดยเป็นสตริงเฉพาะที่มีตัวอักษร ตัวเลข และสัญลักษณ์พิเศษบางอย่างที่อ้างอิงถึงสเปรดชีต และสามารถดึงข้อมูลจาก URL ของสเปรดชีตได้ รหัสสเปรดชีตจะคงที่แม้ว่าชื่อสเปรดชีตจะเปลี่ยนไปก็ตาม
https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit?gid=SHEET_ID#gid=SHEET_ID
- ชีต
หน้าหรือแท็บภายในสเปรดชีต แหล่งข้อมูล
Sheets
แสดงถึงชีต โดยจะมีค่า sheetId
ที่เป็นตัวเลขที่ไม่ซ้ำกันและชีต
title
เป็นส่วนหนึ่งของออบเจ็กต์
SheetProperties
- รหัสชีต
- ตัวระบุที่ไม่ซ้ำกันสำหรับชีตที่เฉพาะเจาะจงภายในสเปรดชีต ซึ่งเป็นจำนวนเต็มเฉพาะที่มีตัวเลขที่อ้างอิงชีต และสามารถ
ได้จาก URL ของสเปรดชีต รหัสชีตจะคงที่แม้ว่าชื่อชีตจะมีการเปลี่ยนแปลงก็ตาม ดูตัวอย่างได้ที่รหัสสเปรดชีต
- เซลล์
ฟิลด์ข้อความหรือข้อมูลแต่ละรายการภายในชีต เซลล์จะจัดเรียงเป็นแถวและคอลัมน์ และจัดกลุ่มเป็นช่วงของเซลล์ได้ แหล่งข้อมูล
Cells
แสดงถึงแต่ละเซลล์ แต่ไม่มีค่ารหัสที่ไม่ซ้ำกัน
แต่พิกัดแถวและคอลัมน์จะระบุเซลล์แทน
- รูปแบบ A1
- ไวยากรณ์ที่ใช้ในการกำหนดเซลล์หรือช่วงของเซลล์ด้วยสตริงที่มีชื่อชีต รวมถึงพิกัดของเซลล์เริ่มต้นและสิ้นสุดโดยใช้ตัวอักษรของคอลัมน์และหมายเลขแถว วิธีนี้เป็นวิธีที่ใช้กันมากที่สุดและมีประโยชน์
เมื่ออ้างอิงช่วงเซลล์แบบสัมบูรณ์
Sheet1!A1:B2
หมายถึงเซลล์ทั้งหมดใน 2 แถวและ 2 คอลัมน์แรกของชีต 1
Sheet1!A:A
หมายถึงเซลล์ทั้งหมดในคอลัมน์แรกของชีต 1
Sheet1!1:2
หมายถึงเซลล์ทั้งหมดใน 2 แถวแรกของชีต 1
Sheet1!A5:A
หมายถึงเซลล์ทั้งหมดในคอลัมน์แรกของชีต 1 ตั้งแต่แถว 5 เป็นต้นไป
A1:B2
หมายถึงเซลล์ทั้งหมดใน 2 แถวแรกและ 2 คอลัมน์แรกของชีตแรกที่มองเห็น
Sheet1
หมายถึงเซลล์ทั้งหมดในชีต1
'Jon's_Data'!A1:D5
หมายถึงเซลล์ทั้งหมดใน 5 แถวแรกและ 4 คอลัมน์แรกของชีตชื่อ "Jon's_Data"
'My Custom Sheet'!A:A
หมายถึงเซลล์ทั้งหมดในคอลัมน์แรกของชีตที่ชื่อ "ชีตที่กำหนดเองของฉัน"
'My Custom Sheet'
หมายถึงเซลล์ทั้งหมดใน "ชีตที่กำหนดเองของฉัน"
ต้องใช้เครื่องหมายคำพูดเดี่ยวสำหรับชื่อชีตที่มีช่องว่างหรืออักขระพิเศษ
เคล็ดลับ: ใช้ชื่อที่แตกต่างกันสำหรับออบเจ็กต์ในสเปรดชีตเมื่อเป็นไปได้ เช่น A1 (ไม่มีเครื่องหมายคำพูด) หมายถึงเซลล์ A1 ในชีตแรกที่มองเห็น 'A1'
หมายถึงชีตที่มีชื่อว่า A1 ในทำนองเดียวกัน Sheet1 จะอ้างอิงถึงชีตที่มีชื่อว่า Sheet1 อย่างไรก็ตาม หากมีช่วงที่ตั้งชื่อว่า "Sheet1" แล้ว Sheet1 จะอ้างอิงถึงช่วงที่ตั้งชื่อและ 'Sheet1'
จะอ้างอิงถึงชีต
- รูปแบบ R1C1
- ไวยากรณ์ที่ใช้ในการกำหนดเซลล์หรือช่วงของเซลล์ด้วยสตริงที่มีชื่อชีต
พร้อมพิกัดเซลล์เริ่มต้นและสิ้นสุดโดยใช้
หมายเลขแถวและหมายเลขคอลัมน์ วิธีนี้พบได้น้อยกว่ารูปแบบ A1
แต่ก็มีประโยชน์เมื่ออ้างอิงช่วงของเซลล์ที่สัมพันธ์กับตำแหน่งของเซลล์ที่กำหนด
Sheet1!R1C1:R2C2
หมายถึง 2 เซลล์แรกใน 2 แถวแรกของชีต 1
R1C1:R2C2
หมายถึง 2 เซลล์แรกใน 2 แถวแรกของชีตแรกที่มองเห็น
Sheet1!R[3]C[1]
หมายถึงเซลล์ที่อยู่ 3 แถวด้านล่างและ 1 คอลัมน์ทางขวาของเซลล์ปัจจุบัน
- ช่วงที่ตั้งชื่อแล้ว
- เซลล์หรือช่วงของเซลล์ที่กำหนดซึ่งมีชื่อที่กำหนดเองเพื่อลดความซับซ้อนของการอ้างอิง
ในแอปพลิเคชัน ทรัพยากร A
FilterView
แสดงถึงช่วงที่มีชื่อ
- ช่วงที่ป้องกันไว้
- เซลล์หรือช่วงของเซลล์ที่กำหนดไว้ซึ่งแก้ไขไม่ได้ ทรัพยากร A
ProtectedRange
แสดงถึงช่วงที่ป้องกันไว้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-29 UTC
[null,null,["อัปเดตล่าสุด 2025-08-29 UTC"],[],[],null,["# Google Sheets API Overview\n\nThe Google Sheets API is a RESTful interface that lets you read and modify a\nspreadsheet's data. The Sheets API lets you:\n\n- Create spreadsheets\n- Read and write spreadsheet cell values\n- Update spreadsheet formatting\n- Manage Connected Sheets\n\nThe following is a list of common terms used in the Sheets API:\n\n*Spreadsheet*\n\n: The primary object in Google Sheets. It can contain multiple `Sheets`, each\n with structured information contained in `Cells`. The\n [`spreadsheets`](/workspace/sheets/api/reference/rest/v4/spreadsheets)\n resource represents a spreadsheet. It contains a unique `spreadsheetId`\n value.\n\n *Spreadsheet ID*\n : The unique identifier for a spreadsheet. It's a particular string\n containing letters, numbers, and some special characters that reference a\n spreadsheet and it can be derived from the spreadsheet's URL. Spreadsheet\n IDs are stable, even if the spreadsheet name changes. \n\n https://docs.google.com/spreadsheets/d/\u003cvar translate=\"no\"\u003eSPREADSHEET_ID\u003c/var\u003e/edit?gid=\u003cvar translate=\"no\"\u003eSHEET_ID\u003c/var\u003e#gid=\u003cvar translate=\"no\"\u003eSHEET_ID\u003c/var\u003e\n\n*Sheet*\n\n: A page or tab within a spreadsheet. The\n [`Sheets`](/workspace/sheets/api/reference/rest/v4/spreadsheets/sheets) resource\n represents a sheet. It contains a unique numeric `sheetId` value and sheet\n `title` as part of the\n [`SheetProperties`](/workspace/sheets/api/reference/rest/v4/spreadsheets/sheets#sheetproperties)\n object.\n\n *Sheet ID*\n : The unique identifier for a specific sheet within a spreadsheet. It's a\n particular integer containing numbers that reference a sheet and it can be\n derived from the spreadsheet's URL. Sheet IDs are stable, even if the sheet\n name changes. For an example, see [Spreadsheet ID](#spreadsheet-id).\n\n*Cell*\n\n: An individual field of text or data within a sheet. Cells are arranged in rows\n and columns, and can be grouped as a range of cells. The\n [`Cells`](/workspace/sheets/api/reference/rest/v4/spreadsheets/cells)\n resource represents each cell, but it doesn't have a unique ID value.\n Instead, row and column coordinates identify the cells.\n\n *A1 notation*\n : A syntax used to define a cell or range of cells with a string that\n contains the sheet name plus the starting and ending cell coordinates using\n column letters and row numbers. This method is the most common and useful\n when referencing an absolute range of cells.\n - `Sheet1!A1:B2` refers to all the cells in the first two rows and columns of Sheet1.\n - `Sheet1!A:A` refers to all the cells in the first column of Sheet1.\n - `Sheet1!1:2` refers to all the cells in the first two rows of Sheet1.\n - `Sheet1!A5:A` refers to all the cells of the first column of Sheet 1, from row 5 onward.\n - `A1:B2` refers to all the cells in the first two rows and columns of the first visible sheet.\n - `Sheet1` refers to all the cells in Sheet1.\n - `'Jon's_Data'!A1:D5` refers to all the cells in the first five rows and four columns of a sheet named \"Jon's_Data.\"\n - `'My Custom Sheet'!A:A` refers to all the cells in the first column of a sheet named \"My Custom Sheet.\"\n - `'My Custom Sheet'` refers to all the cells in \"My Custom Sheet\".\n\n Single quotes are required for sheet names with spaces or special characters.\n\n **Tip** : Where possible, use distinct names for objects in your spreadsheets. For example, A1 (without quotes) refers to cell A1 in the first visible sheet. `'A1'` refers to a sheet with the name A1. Similarly, Sheet1 refers to a sheet with the name Sheet1. However, if there's a named range titled \"Sheet1\", then Sheet1 refers to the named range and `'Sheet1'` refers to the sheet.\n\n *R1C1 notation*\n : A syntax used to define a cell or range of cells with a string that\n contains the sheet name plus the starting and ending cell coordinates using\n row numbers and column numbers. This method is less common than A1 notation,\n but can be useful when referencing a range of cells relative to a given\n cell's position.\n - `Sheet1!R1C1:R2C2` refers to the first two cells in the top two rows of Sheet1.\n - `R1C1:R2C2` refers to the first two cells in the top two rows of the first visible sheet.\n - `Sheet1!R[3]C[1]` refers to the cell that is three rows below and one column to the right of the current cell.\n\n *Named range*\n : A defined cell or range of cells with a custom name to simplify references\n throughout an application. A\n [`FilterView`](/workspace/sheets/api/reference/rest/v4/spreadsheets/sheets#filterview)\n resource represents a named range.\n\n *Protected range*\n : A defined cell or range of cells that cannot be modified. A\n [`ProtectedRange`](/workspace/sheets/api/reference/rest/v4/spreadsheets/sheets#protectedrange)\n resource represents a protected range.\n\nRelated topics\n--------------\n\n- To learn about developing with Google Workspace APIs, including handling\n authentication and authorization, refer to [Develop on\n Google Workspace](/workspace/guides/get-started).\n\n- To learn how to configure and run a Sheets API app, try the\n [JavaScript quickstart](/workspace/sheets/api/quickstart/js)."]]