Home > Back-end >  Exception when openById of Spreadsheet in Google App
Exception when openById of Spreadsheet in Google App

Time:04-25

I implemented a Google Slide Add On which makes a copy of a linked spreadsheets and then opens it (to retrieve all charts in this sheet).

This is the code in question:

// id is the spreadsheet id
var sheetFile = DriveApp.getFileById(id);
var copy = sheetFile.makeCopy(sheetFile.getName()  '_'  'Copy');

Utilities.sleep(200);

// exception happens here
var sheet = SpreadsheetApp.openById(copy.getId());

Unfortunately this results for some sheets in the following error:

Exception: Service Spreadsheets failed while accessing document with id *************.

So I tried to find out why some spreadsheets work and some not and it lookls like that it does not work for not converted spreadsheets from excel. So I tested it by converting one of those excel sheets into a Google Sheet by Menu->File->Convert to Google Sheet.

This did not work... So I played around by replicated the Google Slide with the charts and I found out that I was not able to import the chart to a google slide from this converted spreadsheet. Even if I just create a new chart in this sheet everytime I go to the Slide App and try to insert the chart from this spreadsheet, no charts were displayed in the selection window.

It looks like that something went wrong when converting the excel to Google Sheets, I tried to do the conversion step multiple times... but no change.

[Edit] I also tried to disabling V8 support.

CodePudding user response:

If it's a glitch I'd try to chain the commands this way:

var sheetFile = DriveApp.getFileById(id);
var copy_name = sheetFile.getName()  '_'  'Copy';
var sheet = SpreadsheetApp.openById(sheetFile.makeCopy(copy_name).getId());

This way the command openById won't fire before the file will be copied.

CodePudding user response:

The error message Service Spreadsheets failed while accessing document with id ID you are receiving might in fact be related to this known issue on Google's side.

I suggest you star the issue here as all the updates regarding this will be posted there.

  • Related