Method: spreadsheets.get
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
傳回指定 ID 的試算表。呼叫端必須指定試算表 ID。
根據預設,系統不會傳回格線內的資料。您可以透過下列任一方式加入格狀資料:
對於大型試算表,最佳做法是只擷取所需的特定試算表欄位。
如要只擷取試算表資料的子集,請使用 ranges
網址參數。範圍會使用 A1 標記法指定。您可以定義單一儲存格 (例如 A1
) 或多個儲存格 (例如 A1:D5
)。您也可以從同一份試算表中的其他工作表取得儲存格 (例如 Sheet2!A1:C4
),或一次擷取多個範圍 (例如 ?ranges=A1:D5&ranges=Sheet2!A1:C4
)。限制範圍只會傳回與要求範圍重疊的試算表部分。
HTTP 要求
GET https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}
這個網址使用 gRPC 轉碼語法。
路徑參數
參數 |
spreadsheetId |
string
要要求的試算表。
|
查詢參數
參數 |
ranges[] |
string
要從試算表擷取的範圍。
|
includeGridData |
boolean
如果應傳回格狀資料,則為 true。如果要求中已設定欄位遮罩,系統會忽略這個參數。
|
excludeTablesInBandedRanges |
boolean
如果資料表應排除在區塊範圍中,則為 True。如果未設定,則為 False。
|
回應主體
如果成功,回應主體會包含 Spreadsheet
的執行例項。
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.readonly
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/spreadsheets
https://www.googleapis.com/auth/spreadsheets.readonly
詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-04-30 (世界標準時間)。
[null,null,["上次更新時間:2025-04-30 (世界標準時間)。"],[],[],null,["# Method: spreadsheets.get\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- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nReturns the spreadsheet at the given ID. The caller must specify the spreadsheet ID.\n\nBy default, data within grids is not returned. You can include grid data in one of 2 ways:\n\n- Specify a [field mask](https://developers.google.com/workspace/sheets/api/guides/field-masks) listing your desired fields using the `fields` URL parameter in HTTP\n\n- Set the [includeGridData](/workspace/sheets/api/reference/rest/v4/spreadsheets/get#body.QUERY_PARAMETERS.include_grid_data) URL parameter to true. If a field mask is set, the `includeGridData` parameter is ignored\n\nFor large spreadsheets, as a best practice, retrieve only the specific spreadsheet fields that you want.\n\nTo retrieve only subsets of spreadsheet data, use the [ranges](/workspace/sheets/api/reference/rest/v4/spreadsheets/get#body.QUERY_PARAMETERS.ranges) URL parameter. Ranges are specified using [A1 notation](https://developers.google.com/workspace/sheets/api/guides/concepts#cell). You can define a single cell (for example, `A1`) or multiple cells (for example, `A1:D5`). You can also get cells from other sheets within the same spreadsheet (for example, `Sheet2!A1:C4`) or retrieve multiple ranges at once (for example, `?ranges=A1:D5&ranges=Sheet2!A1:C4`). Limiting the range returns only the portions of the spreadsheet that intersect the requested ranges.\n\n### HTTP request\n\n`GET https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|-----------------|--------------------------------------|\n| `spreadsheetId` | `string` The spreadsheet to request. |\n\n### Query parameters\n\n| Parameters ||\n|-------------------------------|-------------------------------------------------------------------------------------------------------------------|\n| `ranges[]` | `string` The ranges to retrieve from the spreadsheet. |\n| `includeGridData` | `boolean` True if grid data should be returned. This parameter is ignored if a field mask was set in the request. |\n| `excludeTablesInBandedRanges` | `boolean` True if tables should be excluded in the banded ranges. False if not set. |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nIf successful, the response body contains an instance of [Spreadsheet](/workspace/sheets/api/reference/rest/v4/spreadsheets#Spreadsheet).\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.readonly`\n- `https://www.googleapis.com/auth/drive.file`\n- `https://www.googleapis.com/auth/spreadsheets`\n- `https://www.googleapis.com/auth/spreadsheets.readonly`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]