I have a Google Spreadsheet with a custom script that has been working just fine for more than a year and it suddenly started failing.
The problem is very simple to reproduce, but I have no idea what's going on. I create a simple chart from a cell range inside my spreadsheet:
var ss = SpreadsheetApp.getActive(); var sheet = ss.getSheetByName("Sheet1"); var chart = sheet.newChart() .setChartType(Charts.ChartType.LINE) .addRange(sheet.getRange("A1:D4")) .setPosition(5, 5, 0, 0) .build();
The I try to create an image from that EmbeddedChart:
That fails saying<blockquote>
[Service error: Spreadsheets (line xx, file "")]</blockquote>
Weird enough, I tried to work around it and if I insert the generated chart into the sheet and then try to create the image from the chart, it actually works:
var temp = ss.insertSheet(); temp.insertChart(chart); var charts = temp.getCharts(); sheet.insertImage(charts.getBlob(),6,1);
I'm extremely confused, I have no idea what could be the problem. The thing is I have multiple spreadsheets with multiple scripts running some variation of this same code and they are all failing with the same error. So changing every last one of them to use a temp sheet is a lot of work.
I've created <a href="https://code.google.com/p/google-apps-script-issues/issues/detail?id=5549" rel="nofollow">issue 5549 in the issue tracker</a> but nobody has replied so I don't know what to do.
Is there something I'm missing? Can anybody figure this out?Answer1:
This is due to a bug in Spreadsheets -- it's being fixed now. If you avoid attempting to create Blobs from charts, you'll avoid the issue for the time being.