使用Google Sheets API检索单元格中的图像 [英] Retrieve images in cells using Google Sheets API

查看:139
本文介绍了使用Google Sheets API检索单元格中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using the Google Sheets API to return the JSON of a Google Sheet,

例如

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

在其中一个单元格中添加了一个图像,但是在json中显示为空.
如何获取此图片?

In one of the cells I have added an image, but this appears empty in the json.
How can I retrieve this image?

推荐答案

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

This is possible if you use Sheets API v4. If you make a spreadsheets.get request you get access to the =IMAGE(...) formula used in the cell.

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\")"
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

这篇关于使用Google Sheets API检索单元格中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆