使用 Google Sheets API 检索单元格中的图像

Ada*_*dam 4 imagedownload google-sheets-api

我正在使用 Google Sheets API 返回 Google Sheets 的 JSON,

例如

 var url = 'https://spreadsheets.google.com/feeds/list/' + id + '/od6/public/values?alt=json';
Run Code Online (Sandbox Code Playgroud)

在其中一个单元格中,我添加了一个图像,但这在 json 中显示为空。
如何检索此图像?

Eri*_*eda 6

如果您使用Sheets API v4 ,这是可能的。如果您提出spreadsheets.get请求,您可以访问=IMAGE(...)单元格中使用的公式。

GET https://sheets.googleapis.com/v4/spreadsheets/{SPREADSHEET_ID}?
    includeGridData=true&ranges={RANGE_A1}&
    fields=sheets%2Fdata%2FrowData%2Fvalues%2FuserEnteredValue

200 OK

{
  "sheets": [
    {
      "data": [
        {
          "rowData": [
            {
              "values": [
                {
                  "userEnteredValue": {
                    "formulaValue": "=image(\"https://www.google.com/images/srpr/logo3w.png\")"
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)