Method: spreadsheets.get
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Trả về bảng tính tại mã nhận dạng đã cho. Phương thức gọi phải chỉ định mã bảng tính.
Theo mặc định, dữ liệu trong lưới sẽ không được trả về. Bạn có thể đưa dữ liệu lưới vào theo một trong 2 cách:
Chỉ định mặt nạ trường liệt kê các trường bạn muốn bằng cách sử dụng tham số URL fields
trong HTTP
Đặt tham số URL includeGridData
thành true. Nếu bạn đặt mặt nạ trường, tham số includeGridData
sẽ bị bỏ qua
Đối với bảng tính lớn, tốt nhất bạn chỉ nên truy xuất các trường bảng tính cụ thể mà bạn muốn.
Để chỉ truy xuất các tập hợp con dữ liệu trong bảng tính, hãy sử dụng tham số URL ranges
. Phạm vi được chỉ định bằng ký hiệu A1. Bạn có thể xác định một ô (ví dụ: A1
) hoặc nhiều ô (ví dụ: A1:D5
). Bạn cũng có thể lấy các ô từ các trang tính khác trong cùng một bảng tính (ví dụ: Sheet2!A1:C4
) hoặc truy xuất nhiều dải ô cùng một lúc (ví dụ: ?ranges=A1:D5&ranges=Sheet2!A1:C4
). Việc giới hạn dải ô chỉ trả về các phần của bảng tính giao nhau với các dải ô được yêu cầu.
Yêu cầu HTTP
GET https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}
URL sử dụng cú pháp Chuyển mã gRPC.
Tham số đường dẫn
Thông số |
spreadsheetId |
string
Bảng tính cần yêu cầu.
|
Tham số truy vấn
Thông số |
ranges[] |
string
Dải ô cần truy xuất từ bảng tính.
|
includeGridData |
boolean
True nếu cần trả về dữ liệu lưới. Thông số này sẽ bị bỏ qua nếu bạn đã đặt mặt nạ trường trong yêu cầu.
|
excludeTablesInBandedRanges |
boolean
Đúng nếu bạn muốn loại trừ các bảng trong dải ô. Sai nếu không được đặt.
|
Nội dung yêu cầu
Nội dung yêu cầu phải trống.
Nội dung phản hồi
Nếu thành công, nội dung phản hồi sẽ chứa một phiên bản của Spreadsheet
.
Phạm vi uỷ quyền
Yêu cầu một trong các phạm vi OAuth sau:
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
Để biết thêm thông tin, hãy xem Hướng dẫn uỷ quyền.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-04-30 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-04-30 UTC."],[],[],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)."]]