Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve images in cells using Google Sheets API

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

e.g

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

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

like image 684
Adam Avatar asked Sep 14 '16 11:09

Adam


1 Answers

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\")"
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
like image 69
Eric Koleda Avatar answered Oct 20 '22 22:10

Eric Koleda