サンプル
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このセクションでは、Google Sheets API の概要を把握するために使用できるcodelabを紹介します。また、Google スプレッドシートの意図したアクションを API リクエストに変換する方法を示す「レシピ」の例も用意されています。
多くの場合、API を使用して特定のタスクを完了する方法は複数あります。タスクへの取り組み方を決める際は、次の点に注意してください。
レシピ
このセクションの例では、Sheets の一般的なアクションを Sheets API v4 リクエストとして表現する方法を示します。
これらの例は、言語に依存しない HTTP リクエストの形式で示されています。Google API クライアント ライブラリを使用して特定の言語で Sheets API リクエスト プロトコルを実装する方法については、セルの値の読み取りと書き込みガイドとスプレッドシートの更新ガイドをご覧ください。
このセクションのレシピは、次のカテゴリに分類されています。
- 基本的な読み取り - シートから値を読み取る方法を示すレシピ。
- 基本的な書き込み - シートに値を書き込む方法を示すレシピ。
- 基本的な書式設定 - シートとセルの外観を変更する方法を示すレシピ。
- グラフ - シートでグラフを作成して変更する方法を示すレシピ。
- 条件付き書式 - 条件に基づいてセルの外観を変更する方法を示すレシピ。
- データ オペレーション - スプレッドシートでデータを作成、移動、操作する方法を示すレシピ。
- 名前付き範囲と保護された範囲 - スプレッドシートで名前付き範囲と保護された範囲を作成、更新、削除する方法を示すレシピ。
- ピボット テーブル - シートでピボット テーブルを作成する方法を示すレシピ。
- 行と列の操作 - 行と列の追加、削除、移動、プロパティの更新方法を示すレシピ。
- シートの操作 - シートの作成、クリア、コピー、削除の方法と、シートのプロパティを制御する方法を示すレシピ。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-29 UTC。
[null,null,["最終更新日 2025-08-29 UTC。"],[],[],null,["# Samples\n\nThis 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-------\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."]]