【问题标题】:Google Sheets JSON feeed - I want the data not the schemaGoogle 表格 JSON 提要 - 我想要数据而不是架构
【发布时间】:2023-03-20 16:06:01
【问题描述】:

使用 Postman,调用 GET https://spreadsheets.google.com/feeds/list/1XJgmvAGNmpyJieZTh40PuoKHoKOI1CJlMqSStu75fWo/od6/public/basic?alt=json&range=(A1:F101).getValue()

我得到一个带有 xml 架构的 JSON 提要,例如 { “版本”:“1.0”, "编码": "UTF-8", “喂养”: { "xmlns": "http://www.w3.org/2005/Atom", "xmlns$openSearch": "http://a9.com/-/spec/opensearchrss/1.0/", "xmlns$gsx": "http://schemas.google.com/spreadsheets/2006/extended", “ID”: { "$t": "https://spreadsheets.google.com/feeds/list/1XJgmvAGNmpyJieZTh40PuoKHoKOI1CJlMqSStu75fWo/od6/public/basic" }, “更新”: { "$t": "2020-02-27T00:58:42.663Z" }, “类别”: [ { "方案": "http://schemas.google.com/spreadsheets/2006", “术语”:“http://schemas.google.com/spreadsheets/2006#list”。

我只想要工作表中的数据。

我使用什么内联脚本来获取一系列数据,例如 A1:C6

或所有数据(仅)

提前致谢

【问题讨论】:

标签: json google-apps-script google-sheets


【解决方案1】:

问题

如何通过 GET 请求从电子表格中获取数据值?

回答

使用这种格式:

https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/RANGE?majorDimension=COLUMNS&key=YOUR_API_KEY

所以最后应该是这样的:

https://sheets.googleapis.com/v4/spreadsheets/1XJgmvAGNmpyJieZTh40PuoKHoKOI1CJlMqSStu75fWo/values/A1:F101?majorDimension=COLUMNS&key=[YOUR_API_KEY]

试试API Explorer,这样您就可以根据自己的需要进行调整

回复是:

{
  "range": "Sheet1!A1:C21",
  "majorDimension": "COLUMNS",
  "values": [
    [
      "a1",
      "a2",
...
      "c19",
      "c20",
      "c21"
    ]
  ]
}

现在是时候用forEach 或任何你喜欢的格式来格式化它了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-29
    • 1970-01-01
    • 1970-01-01
    • 2012-01-20
    • 2012-05-29
    • 2018-09-07
    • 2012-11-03
    相关资源
    最近更新 更多