0

Is there a way, using the Google Sheets API, to transfer images from one Google Sheet to another that have been added using Insert > Image?

I had a look at the possibilities of Importrange but there doesn't seem to be a way to transfer images using that.

Ryan M
  • 18,333
  • 31
  • 67
  • 74
orschiro
  • 19,847
  • 19
  • 64
  • 95
  • It depends on how the image is added to the sheet. Through formula `=IMAGE`? Via `Insert > Image`? – Iamblichus Aug 05 '20 at 13:02
  • The latter, Insert > Image – orschiro Aug 05 '20 at 13:31
  • Attention reviewers: asking how to do something via a platform's built-in web API is _not_ "Seeking recommendations for books, tools, software libraries, and more." It's a perfectly on-topic question. – Ryan M Aug 19 '20 at 10:05

2 Answers2

2

Answer:

Unfortunately, there is currently no way to retrieve images added through Insert > Image via Sheets API, so all you have are several roundabout ways, which will only be appropriate in certain circumstances.

Feature Requests:

There are several feature requests in Issue Tracker regarding image handling in Sheets API, I'd suggest you to star these in order to keep track of them and to help prioritize its implementation:

Workarounds:

Option 1. Set image through its URL:

If a URL of the image is available and you want to write the image to a specific cell (not over cells), you could just add the formula =IMAGE(your-image-url) to the desired cell via spreadsheets.values.update.

Or, if you're open to using Apps Script, you could use insertImage(url, column, row).

Option 2. Copy corresponding range:

If the image was added via Insert > Images > Image in cell and the destination sheet is on the same spreadsheet as the source sheet, you could make a CopyPasteRequest or a CutPasteRequest to copy or move the range containing the image to the destination sheet (see spreadsheets.batchUpdate).

Option 3. Copy the entire sheet:

If the image was added via Insert > Images > Image over cells, or if the destination sheet is not on the same spreadsheet as the source sheet, your only option would be to copy the entire sheet via spreadsheets.sheets.copyTo.

Iamblichus
  • 18,540
  • 2
  • 11
  • 27
0

You can download a zip file with the sheet in html format using Google API. It will contain all images, no matter how were they added.

  1. Get Your API Key, from Google developers Console

  2. Get a File ID of a google spreadsheet with permissions set to "Anyone with the link".

  3. Now you're ready to call the api (with curl or browser window): https://www.googleapis.com/drive/v3/files/{FILE_ID}/export?mimeType=application%2Fzip&key={YOUR API KEY}