My script inserts a PNG image in the spreadsheet by insertImage() function.
const Sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
const File = DriveApp.getFileById("**********"); // PNG file in Google Drive
const Blob = File.getBlob();
Sheet.insertImage(Blob, 1, 9, 20, 30).setHeight(100).setWidth(100);
}
It seems to work fine, but if I export the spreadsheet to PDF, the image doesn't appear in the PDF. After reloading the spreadsheet on the browser, I can export to PDF with the image with no problem. How can I export to PDF with the image without reloading the spreadsheet? (SpreadsheetApp.flush() didn't help it.)