Taking single sheet Google spreadsheet, making it

2019-09-08 17:11发布

问题:

I've been hours at this trying every which way and any kind of function that might result in something and I'm getting nowhere and frustrated. The code (stripped to the bare essentials):

function alone() {
    try {
      spreadSheetFile = DocsList.getFileById("KEY FOR A GOOGLE SPREADSHEET").getAs('application/pdf');
    }
    catch (e) {
      Logger.log ("Catched something: "+e+"\n"+e.stack);
    }
      createFile('test file', content, 'application/pdf');
}

Getting the dreaded "Unexpected exception upon serializing continuation" and not even going to the catch, so nothing logged. I've used various methods tagged onto the end of "getAs", getBlob(), just about everything. I'm guessing this is just another part of Google code that's nogga, nogga, noggonna work here anymore.

回答1:

your syntax is simply wrong... try like this and it will work : (the sheet in this example has a single cell with value "empty sheet" and is shared)

function alone() {
try { 
 var spreadSheetFile = DocsList.getFileById("0AjUO-g3TOXkodHNtUUxwMEY5UHNCaTE3TDZLSmgweWc")
 var pdf = spreadSheetFile.getAs('application/pdf'); 
} catch (e) {
  Logger.log ("Catched something: "+e+"\n"+e.stack);
}
 DocsList.createFile(pdf)
}