0

I am using google sheet API V4 to update spreadsheet in my google drive. I can use below API to update value of the spreadsheet.

Google::Apis::SheetsV4::BatchUpdateValuesRequest.new(data: data, value_input_option: "RAW")

Now I want to insert an image to specific cell range. Is it possible by using this method or is there a way with ruby google-api-client ?

Tiktac
  • 966
  • 1
  • 12
  • 32

1 Answers1

0

Looking in the google documentation for Sheets API it seems this feature is not implemented.

There is one google engineer responding to this same question long time ago but seems to still not be implemented. Insert image into Google Sheets cell using Google Sheets API

As he suggested you could try to inset the =IMAGE function. But take into consideration that the image needs to be already on accessible on the internet.


What you can do is change position an already existing image inside the sheet. Take a look at UpdateEmbeddedObjectPositionRequest.

Raserhin
  • 2,516
  • 1
  • 10
  • 14
  • How can I use =IMAGE formula from ruby? It seem it is inserting an image by using this macro in spreadsheet, not from ruby. – Tiktac Feb 27 '20 at 09:52
  • You cannot upload an image from your local machine to Sheets directly through the API. As I said this feature is not implemented. – Raserhin Feb 27 '20 at 10:20
  • Oh, got it, I though I can update sheet cell value equal to '=image(url,..)', so an image can be uploaded to the cell? – Tiktac Feb 27 '20 at 10:45
  • You can change the URL to point to another image that is already online, think of imgstack, Drive, Google Cloud Storage, or whatever you can use. You cannot upload the image to the sheets directly from the API. Hope that makes sense. – Raserhin Feb 27 '20 at 10:51