從試算表資料 API 擷取 JSON 資訊提供的簡單範例
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
警告:本頁面說明 Google 的舊版 API (即 Google Data API);該 API 只與 Google Data API 目錄中列出的 API 相關,其中許多 API 已由新版 API 取代。如需特定新的 API 的相關資訊,請參閱新 API 的說明文件。如要瞭解如何使用新版 API 授權要求,請參閱 Google 帳戶驗證與授權。
簡介
這個範例示範如何使用 Sheets Data API 提供的 JSON 輸出格式,在試算表中顯示特定工作表的清單或儲存格資訊提供。這可讓您查詢試算表的公開清單或儲存格資訊提供,並取得結果項目作為 JSON 物件。如要使用新的 JSON 資訊提供,請建立 src
值為
http://spreadsheets.google.com/feeds/feed/key/worksheet/public/basic?alt=json-in-script&callback=myFunc
其中 feed
是動態饋給的類型,key
是您要擷取的試算表鍵,worksheet
是工作表的位置或唯一識別碼,myFunc
則是傳遞您傳遞 JSON 物件的回呼函式名稱。如要進一步瞭解 Google Data API 的 JSON 輸出支援,請參閱 JSON 輸出支援說明文件。
注意:只有已發布的試算表才支援未經驗證的動態饋給。
注意:其他資訊提供類型以及顯示設定和投影值可以與 JSON 輸出支援搭配使用。如要進一步瞭解其他資訊提供類型,以及瀏覽權限和投影值,請參閱 Sheets Data API 說明文件。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2023-03-01 (世界標準時間)。
[null,null,["上次更新時間:2023-03-01 (世界標準時間)。"],[],[],null,["# Simple example of retrieving JSON feeds from Spreadsheets Data API\n\n**Warning** : This page is about Google's older APIs, the Google Data APIs; it's relevant only to the APIs that are listed in the [Google Data APIs directory](/gdata/docs/directory), many of which have been replaced with newer APIs. For information about a specific new API, see the new API's documentation. For information about authorizing requests with a newer API, see [Google Accounts Authentication and Authorization](/accounts).\n| Version v4 of the [Google Sheets API](/sheets) is now available! This [migration guide](/sheets/guides/migration) shows how to update applications to use v4.\n\n### Introduction\n\nThis sample demonstrates displaying a list or cells feed for a particular worksheet in a spreadsheet using the JSON output format provided by the Spreadsheets Data API. This allows you to query a spreadsheet's public list or cell feed and get the resulting entries returned as JSON objects. To use the new JSON feed, create a script element whose `src` value is\n\u003e `http://spreadsheets.google.com/feeds/`**feed** `/`**key** `/`**worksheet** `/public/basic?alt=json-in-script&callback=`**myFunc**\n\nwhere **`feed`** is the type of feed, **`key`** is the key of the spreadsheet you want to retrieve, the **`worksheet`** is the positional or unique identifier of the worksheet, and **`myFunc`** is the name of your callback function that is passed the JSON object. For more information on JSON output support for Google Data APIs please see our [JSON output support documentation](/gdata/json).\n\n**Note:** Retrieving a feed without authentication is only supported for published spreadsheets.\n\n**Note:** Other feed types and visibility and projection values may be used with JSON output support. For more information on other feed types, and visibility and projection values please see the [Spreadsheets Data API](/google-apps/spreadsheets) documentation.\n\n### Demo\n\nSpreadsheet: http://spreadsheets.google.com/feeds/ list cells / / /public/values OK"]]