Method: spreadsheets.values.batchGet
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
傳回試算表中一或多個值的範圍。呼叫端必須指定試算表 ID 和一或多個範圍。
HTTP 要求
GET https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values:batchGet
這個網址使用 gRPC 轉碼語法。
路徑參數
參數 |
spreadsheetId |
string
要擷取資料的工作表 ID。
|
查詢參數
參數 |
ranges[] |
string
要擷取值的範圍的 A1 標示法或 R1C1 標示法。
|
majorDimension |
enum (Dimension )
結果應使用的主要維度。 舉例來說,如果試算表資料為 A1=1,B1=2,A2=3,B2=4 ,要求 ranges=["A1:B2"],majorDimension=ROWS 會傳回 [[1,2],[3,4]] ,而要求 ranges=["A1:B2"],majorDimension=COLUMNS 會傳回 [[1,3],[2,4]] 。
|
valueRenderOption |
enum (ValueRenderOption )
輸出內容應如何呈現值。預設轉譯選項為 ValueRenderOption.FORMATTED_VALUE 。
|
dateTimeRenderOption |
enum (DateTimeRenderOption )
日期、時間和時間長度應如何在輸出內容中顯示。如果 valueRenderOption 為 FORMATTED_VALUE ,系統會忽略這項屬性。預設的 dateTime 轉譯選項為 SERIAL_NUMBER 。
|
回應主體
在試算表中擷取多個值範圍時的回應。
如果成功,回應主體會含有以下結構的資料:
JSON 表示法 |
{
"spreadsheetId": string,
"valueRanges": [
{
object (ValueRange )
}
]
} |
欄位 |
spreadsheetId |
string
擷取資料的試算表 ID。
|
valueRanges[] |
object (ValueRange )
要求的值。ValueRanges 的順序與要求範圍的順序相同。
|
授權範圍
需要下列其中一種 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-03-22 (世界標準時間)。
[null,null,["上次更新時間:2025-03-22 (世界標準時間)。"],[],[],null,["# Method: spreadsheets.values.batchGet\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.BatchGetValuesResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nReturns one or more ranges of values from a spreadsheet. The caller must specify the spreadsheet ID and one or more ranges.\n\n### HTTP request\n\n`GET https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values:batchGet`\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 retrieve data from. |\n\n### Query parameters\n\n| Parameters ||\n|------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `ranges[]` | `string` The [A1 notation or R1C1 notation](https://developers.google.com/workspace/sheets/api/guides/concepts#cell) of the range to retrieve values from. |\n| `majorDimension` | `enum (`[Dimension](/workspace/sheets/api/reference/rest/v4/Dimension)`)` The major dimension that results should use. For example, if the spreadsheet data is: `A1=1,B1=2,A2=3,B2=4`, then requesting `ranges=[\"A1:B2\"],majorDimension=ROWS` returns `[[1,2],[3,4]]`, whereas requesting `ranges=[\"A1:B2\"],majorDimension=COLUMNS` returns `[[1,3],[2,4]]`. |\n| `valueRenderOption` | `enum (`[ValueRenderOption](/workspace/sheets/api/reference/rest/v4/ValueRenderOption)`)` How values should be represented in the output. The default render option is [ValueRenderOption.FORMATTED_VALUE](/workspace/sheets/api/reference/rest/v4/ValueRenderOption#ENUM_VALUES.FORMATTED_VALUE). |\n| `dateTimeRenderOption` | `enum (`[DateTimeRenderOption](/workspace/sheets/api/reference/rest/v4/DateTimeRenderOption)`)` How dates, times, and durations should be represented in the output. This is ignored if [valueRenderOption](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/batchGet#body.QUERY_PARAMETERS.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 must be empty.\n\n### Response body\n\nThe response when retrieving more than one 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, \"valueRanges\": [ { object (/workspace/sheets/api/reference/rest/v4/spreadsheets.values#ValueRange) } ] } ``` |\n\n| Fields ||\n|-----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `spreadsheetId` | `string` The ID of the spreadsheet the data was retrieved from. |\n| `valueRanges[]` | `object (`[ValueRange](/workspace/sheets/api/reference/rest/v4/spreadsheets.values#ValueRange)`)` The requested values. The order of the ValueRanges is the same as the order of the requested ranges. |\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)."]]