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
如需了解详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-22。
[null,null,["最后更新时间 (UTC):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)."]]