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.
Phần này giới thiệu một codelab mà bạn có thể sử dụng để làm quen với Google Sheets API. Ngoài ra, chúng tôi cũng cung cấp một bộ ví dụ về "công thức" minh hoạ cách chuyển đổi một thao tác dự kiến trên Google Trang tính thành một yêu cầu API.
Thường thì có nhiều cách để hoàn thành một tác vụ nhất định bằng API. Khi bạn quyết định cách tiếp cận một nhiệm vụ, hãy lưu ý những điều sau:
Nếu bạn cần đọc hoặc ghi giá trị ô, thì bộ sưu tập spreadsheets.values sẽ là lựa chọn phù hợp hơn so với bộ sưu tập spreadsheets. Giao diện của phương thức trước dễ sử dụng hơn cho các thao tác đọc/ghi đơn giản.
Đảm bảo tính nguyên tử của tất cả các thay đổi trong lô.
Recipe
Các ví dụ được liệt kê trong phần này minh hoạ cách thể hiện các thao tác phổ biến trong Trang tính dưới dạng yêu cầu Sheets API phiên bản 4.
Các ví dụ này được trình bày dưới dạng yêu cầu HTTP để không phụ thuộc vào ngôn ngữ. Để tìm hiểu cách triển khai các giao thức yêu cầu của API Trang tính bằng một ngôn ngữ cụ thể thông qua thư viện ứng dụng API của Google, hãy xem hướng dẫn Đọc và ghi giá trị ô và Cập nhật bảng tính.
Các công thức trong phần này được chia thành các danh mục sau:
Đọc cơ bản – Các công thức cho biết cách đọc giá trị từ một trang tính.
Viết cơ bản – Các công thức cho biết cách ghi giá trị vào một trang tính.
Định dạng cơ bản – Công thức cho biết cách thay đổi giao diện của trang tính và ô.
Biểu đồ – Công thức cho biết cách tạo và sửa đổi biểu đồ trong một trang tính.
Định dạng có điều kiện – Công thức cho biết cách thay đổi giao diện của ô dựa trên các điều kiện.
Thao tác dữ liệu – Công thức cho biết cách tạo, di chuyển và thao tác dữ liệu trong bảng tính.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-04 UTC."],[],[],null,["This section presents a\n[codelab](https://codelabs.developers.google.com/codelabs/sheets-api/) you can\nuse to become familiar with the Google Sheets API. Also provided are a set of\n\"recipe\" examples that demonstrate how to translate an intended Google Sheets\naction into an API request.\n\nOften there's more than one way to complete a given task with the API. When\nyou're deciding on how to approach a task, keep the following in mind:\n\n- If you need to read or write cell values, the [`spreadsheets.values`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values) collection is a better choice than the [`spreadsheets`](/workspace/sheets/api/reference/rest/v4/spreadsheets) collection. The former's interface is easier to use for simple read/write operations.\n- Wherever possible, use the batch methods\n ([`spreadsheet.batchUpdate`](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate),\n [`spreadsheet.values.batchGet`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/batchGet),\n and\n [`spreadsheet.values.batchUpdate`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/batchUpdate))\n to bundle multiple requests into a single method call. Using these batch\n methods improves efficiency as they:\n\n - Reduce client HTTP overhead.\n - Reduce the number of queries made.\n - Reduce the number of revisions on the doc.\n - Ensure atomicity of all the changes in the batch.\n\nRecipes\n\nThe examples listed in this section demonstrate how to express common actions in\nSheets as Sheets API v4 requests.\n\nThese examples are presented in the form of HTTP requests to be language\nneutral. To learn how to implement Sheets API request protocols in a\nspecific language using Google API client libraries, see the [Read \\& write cell\nvalues](/workspace/sheets/api/guides/values) and [Update\nspreadsheets](/workspace/sheets/api/guides/batchupdate) guides.\n\nRecipes in this section are divided into the following categories:\n\n- [Basic reading](/workspace/sheets/api/samples/reading)---Recipes that show how to read values from a sheet.\n- [Basic writing](/workspace/sheets/api/samples/writing)---Recipes that show how to write values to a sheet.\n- [Basic formatting](/workspace/sheets/api/samples/formatting)---Recipes that show how to change the appearance of sheets and cells.\n- [Charts](/workspace/sheets/api/samples/charts)---Recipes that show how to create and alter charts in a sheet.\n- [Conditional formatting](/workspace/sheets/api/samples/conditional-formatting)--- Recipes that show how to alter cell appearance based on conditions.\n- [Data operations](/workspace/sheets/api/samples/data)---Recipes that show how to create, move, and manipulate data in a spreadsheet.\n- [Named \\& protected\n ranges](/workspace/sheets/api/samples/ranges)---Recipes that show how to create, update, and remove named and protected ranges in a spreadsheet.\n- [Pivot tables](/workspace/sheets/api/samples/pivot-tables)---Recipes that show how to create pivot tables in a sheet.\n- [Row \\& column\n operations](/workspace/sheets/api/samples/rowcolumn)---Recipes that show how to add, remove, and move rows and columns, and update their properties.\n- [Sheet operations](/workspace/sheets/api/samples/sheet)---Recipes that show how to create, clear, copy, and delete sheets, and also control their properties."]]