1

I have a problem with GAS when I try to put an image into a spreadsheet. If I add the image from spreadsheet by menu: Insert -> Image -> from Google Drive, I view my image in Spreadsheet and when I print it I can view the image in print preview and in the paper printed. Instead if I add the images from GAS, I view the image in the spreadsheet like the first image, but when I try to print the spreadsheet, in the print preview I view only one image, the first created by "menu" and not the second created by script. So, if I try to print, the result paper is the same: only one image, only the first created by "menu".

The GAS code I used to insert the image is this:

var spScheda = SpreadsheetApp.openById(ID_SPREADSHEET_IN_DRIVE);  
var schedaSheet1 = spScheda.getSheetByName("Sheet1");
var imgFile = DriveApp.getFileById(ID_JPG_IN_DRIVE);
var blobJPG = imgFile.getBlob();
schedaSheet1.insertImage(blobJPG, 3, 122);
SpreadsheetApp.flush();

Or with the Thumbnail:

var spScheda = SpreadsheetApp.openById(ID_SPREADSHEET_IN_DRIVE);
var schedaSheet1 = spScheda.getSheetByName("Foglio1");
var imgFile = DriveApp.getFileById(ID_JPG_IN_DRIVE);
var blobThumbnail = imgFile.getThumbnail();
schedaSheet1.insertImage(blobThumbnail, 3, 122);
SpreadsheetApp.flush();

Can anyone help me?

enter image description here enter image description here

Regards, Laura

Laura Zecchin
  • 95
  • 2
  • 5
  • does the image *have* to be inserted like that ? could it be in a cell instead ? If it can then [this post](http://stackoverflow.com/questions/15461170/upload-an-image-to-a-google-spreadsheet) gives an answer using a formula in a cell : `range.setFormula('=image("https://drive.google.com/uc?export=view&id='+'image ID in drive'+'")');` – Serge insas Jan 04 '16 at 11:47
  • Also with: `range.setFormula('=image("https://drive.google.com/uc?export=view&id='+'image ID in drive'+'")');` The result is the same: in the spreadsheet the image is visible but in print preview and in the press the image there isn't. – Laura Zecchin Jan 04 '16 at 14:14
  • in my SS the images are printed and visible in preview as well, for example : https://docs.google.com/spreadsheets/d/1X3EnT6PJN0aochHzBNcLYzyHP78-XT9yOnnpQbQ4If0/edit#gid=0 see last pages (long doc ;-) – Serge insas Jan 04 '16 at 14:51
  • But, How do you load the image in the SS? By GAS? In my SS the images are loaded by the code in my first post and you can see that the images aren't visible in print preview [link] (https://docs.google.com/spreadsheets/d/1S-yhL7MZeqhnP4yVczQ2LP9ppAPYEAf2iDEBNf_wZ7c/edit?usp=sharing) – Laura Zecchin Jan 05 '16 at 15:18
  • images are loaded by a script too, I don't know why we observe a different behavior...I guess you checked the access authorizations on these images and set it to "public even anonymous"... sorry I can't help on this. I'd suggest to report it as an issue on the [issue tracker.](https://code.google.com/p/google-apps-script-issues/issues/list) – Serge insas Jan 05 '16 at 17:45
  • Also with the public authorization on images the behavior is the same and I don't view the images loaded by script in the press. Now with the authorization set to public, can you view all 3 images in print preview of my [spreadsheet](https://docs.google.com/spreadsheets/d/1S-yhL7MZeqhnP4yVczQ2LP9ppAPYEAf2iDEBNf_wZ7c/edit?usp=sharing)? I've already open an issue in the [issue tracker](https://code.google.com/p/google-apps-script-issues/issues/detail?id=5639&thanks=5639&ts=1451984602). – Laura Zecchin Jan 07 '16 at 08:57
  • I see the 3 of them in the sheet but only one in print preview indeed... no explanation. When I have a bit more time I'll try to reproduce this issue on a new SS, I'll post here if I find something. – Serge insas Jan 07 '16 at 10:56
  • Thanks @Serge, I don't understand what is the problem. I'm waiting for news or other assumptions. – Laura Zecchin Jan 08 '16 at 12:34

0 Answers0