简体   繁体   中英

Load Image from Google Sheets using Google Apps Script

I have some data along with images in a Google Sheet. I am sending the data as a JSON response and I have deployed the script as a web app.

I am using the code:

SpreadsheetApp.openByID("<sheet_id>").getSheets[0].getDataRange().getValues()

I am able to load the data properly but I am not able to load the images. For the cells with image, I get Empty String.

Can you please suggest a way to load images using the same script?

If it can provide a URL to my image saved in the sheet, then also it will solve my problem as I just wan't to display the image.

At the moment, you can obtain the image URL but under very special conditions:

  1. The image has to be defined as an "Over cell" image (it cannot be an "In-cell image", as they are not supported by Apps Script).

  2. The images have to be inserted by URL (not by uploading it from your local system).

The way to do it would be to:

  1. Obtain the Sheet you want the images of.
  2. Obtain its images using the getImages() method.
  3. Obtain the URL of each image by using the getUrl() method.

If you are interested in the possibility of obtaining "in-cell" images more easily, I suggest you visit the feature requests in the Google's Public Issue Tracker or consider creating a brand new one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM