node-google-spreadsheet
node-google-spreadsheet copied to clipboard
Images in cells
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.
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?
I tried with {raw: true}
and it still deleted the image in the row, even though that cell was not updated.
I ended up working around this issue by just saving the changed cells via sheet.saveUpdatedCells();
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
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…
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.