範例
本節將介紹程式碼研究室,讓您熟悉 Google 試算表 API。我們也提供一組「食譜」範例,說明如何將指定的 Google 試算表動作轉譯為 API 要求。
使用 API 完成特定工作時,通常有多種方法可供選擇。決定如何處理工作時,請注意下列事項:
食譜
本節列出的範例說明如何將 Google 試算表中的常見動作,以 Google 試算表 API v4 要求的形式表示。
這些範例以 HTTP 要求的形式呈現,以便不受語言限制。如要瞭解如何使用 Google API 用戶端程式庫,以特定語言實作 Sheets API 要求通訊協定,請參閱「讀取及寫入儲存格值」和「更新試算表」指南。
本節的食譜分為以下類別:
- 基本讀取作業:說明如何從工作表讀取值的秘訣。
- 基本寫入作業:說明如何將值寫入工作表的秘訣。
- 基本格式設定:說明如何變更試算表和儲存格的外觀。
- 圖表:說明如何在試算單中建立及變更圖表的秘訣。
- 條件式格式設定:顯示如何根據條件變更儲存格外觀的食譜。
- 資料作業:說明如何在試算表中建立、移動及操控資料的秘訣。
- 命名及受保護的範圍:這類食譜會說明如何在試算表中建立、更新及移除命名及受保護的範圍。
- 資料透視表:說明如何在工作表中建立資料透視表的食譜。
- 資料列和欄操作:說明如何新增、移除及移動資料列和欄,以及更新其屬性。
- 工作表作業:說明如何建立、清除、複製及刪除工作表,以及控管其屬性的食譜。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-12-21 (世界標準時間)。
[null,null,["上次更新時間:2024-12-21 (世界標準時間)。"],[[["This section introduces the Google Sheets API through a codelab and practical \"recipe\" examples for common tasks."],["It provides guidance on choosing efficient API methods, such as using `spreadsheets.values` for cell operations and batch methods for multiple requests."],["The \"Recipes\" section offers ready-to-use code snippets for a wide array of spreadsheet interactions, categorized for easy navigation."],["Examples are presented as HTTP requests and can be implemented in various programming languages using Google API client libraries."],["Users can explore recipes on reading, writing, formatting, charts, data operations, ranges, pivot tables, row/column operations, and sheet management."]]],["The content provides a Google Sheets API codelab and \"recipe\" examples for translating actions into API requests. When manipulating cell values, prioritize the `spreadsheets.values` collection. Use batch methods (`batchUpdate`, `batchGet`) to improve efficiency by bundling multiple requests. The recipes demonstrate common Sheets actions categorized into: reading, writing, formatting, charts, conditional formatting, data operations, named/protected ranges, pivot tables, row/column operations, and sheet operations. The HTTP request examples are language-neutral.\n"]]