I'm trying to use Sheets API to update a CellImage.
I'd like to use Sheets API rather than SpreadsheetApp because it will be batched with several other operations.
Creating the cell image:
const sheetId = '0000000000000';
const photoId = '0000000000000';
const image = DriveApp.getFileById(photoId);
const mimeType = image.getMimeType();
const base64 = Utilities.base64Encode(image.getBlob().getBytes());
const cellImage = SpreadsheetApp.newCellImage()
.setSourceUrl(`data:${mimeType};base64,${base64}`)
.build();
This works:
SpreadsheetApp.openById(sheetId)
.getSheets()[0]
.getRange(1,1)
.setValue(cellImage);
But this results in "CellImage" written in the cell, rather than displaying the image:
Sheets.Spreadsheets.Values.update(
{ values: [[cellImage]] },
sheetId,
'A1',
{valueInputOption: 'RAW'}
I've tried valueInputOption: "USER_ENTERED" too, but the same result.
Is there a way of using Sheets API to update a cellimage?
Thanks!