node-google-spreadsheet icon indicating copy to clipboard operation
node-google-spreadsheet copied to clipboard

Images in cells

Open DanielBailey-web opened this issue 2 years ago • 6 comments

Problem

When saving, images that are located in cells with "place image inside cell" in google sheets are removed.

It would be nice if they weren't destroyed just by saving the row.

Aside

Also, it would be nice if we were able to move them around. But currently, it looks like they are not visible to this api. I don't know if that is on your end or on google's.

DanielBailey-web avatar Mar 16 '22 05:03 DanielBailey-web

I'd have to do some digging... The row based methods in general really try to simplify things to handle most use cases, which means it uses certain google endpoints which dont necessarily support everything.

Have you tried using the raw option on the row save method?

theoephraim avatar May 14 '22 05:05 theoephraim

I tried with {raw: true} and it still deleted the image in the row, even though that cell was not updated.

jbrown215 avatar Jul 29 '22 15:07 jbrown215

I ended up working around this issue by just saving the changed cells via sheet.saveUpdatedCells();

jbrown215 avatar Jul 29 '22 19:07 jbrown215

I also can't figure out how to retrieve information about the image in the cell. Using the Sheet UI I insert an image into the cell. With the API I get the data with getRows, but the cell is an empty string.

I know the image URL is there. If I export the Sheet to HMLT page the image exists on https://lh6.googleusercontent.com URL.

Does anyone know how to get the image cell URL with API?

Update: Looks like this is currently not possible: https://stackoverflow.com/questions/56138090/how-to-get-an-image-in-cell-url-from-the-google-sheets-api

pzagor2 avatar Nov 25 '22 10:11 pzagor2

I’d be surprised if there wasn’t some way to get it using the cell-based API, although perhaps this library will need some modification to do so.

I’m not surprised though that the simplified api calls that the row based methods use don’t support it…

theoephraim avatar Nov 25 '22 16:11 theoephraim

I played around with the API explorer on this page https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get

I could not find a way to get the in-cell uploaded image URL.

pzagor2 avatar Nov 28 '22 09:11 pzagor2