代码之家  ›  专栏  ›  技术社区  ›  Adam

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

  •  7
  • Adam  · 技术社区  · 8 年前

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

    例如

     var url = 'https://spreadsheets.google.com/feeds/list/' + id + '/od6/public/values?alt=json';
    

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

    1 回复  |  直到 6 年前
        1
  •  6
  •   Eric Koleda    8 年前

    如果您使用 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\")"
                      }
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }