Method: spreadsheets.get
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
返回指定 ID 对应的电子表格。调用方必须指定电子表格 ID。
默认情况下,系统不会返回网格中的数据。您可以通过以下 2 种方式之一添加网格数据:
对于大型电子表格,最佳实践是仅检索所需的特定电子表格字段。
如需仅检索部分电子表格数据,请使用 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
如需了解详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-04-29。
[null,null,["最后更新时间 (UTC):2025-04-29。"],[],[],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)."]]