60624

Google Apps Script fails to generate image from EmbeddedChartBuilder

Question:

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:

sheet.insertImage(chart.getBlob(),6,1);

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[0].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.

Recommend

  • “Cannot call SpreadsheetApp.getUi() from this context” error while not using getUi() on time-based t
  • “Cannot call SpreadsheetApp.getUi() from this context” error while not using getUi() on time-based t
  • “Cannot call SpreadsheetApp.getUi() from this context” error while not using getUi() on time-based t
  • Scaling data in R, resulting in error: “length of 'center' must equal the number of column
  • How to connect Azure Web Sites to a Worker Role (TCP) through a (regional) vnet? Is it possible?
  • Catch and Continue? C#
  • Changing grid template columns breaks layout
  • How to compress a tar file in a tar.gz without directory?
  • Rails - Rake error: Library not loaded
  • Angular Material Table rowspan columns based on dataSource object array property size
  • Is there a way to “resource” by bash_profile without restarting terminal? [duplicate]
  • Filter magento order collection
  • Escaping bash variable
  • Is there an alternative for sys.exit() in python?
  • Why this imagesc-imshow with Colormap not Working in Matlab?
  • Thymeleaf + Spring-Boot - why can't I access static resources?
  • Core Data information in application
  • Error trying to download using filnename format
  • Deadlock in range over channel in pipeline with multiple waitgroups
  • Using HTML POST to upload file via PHP
  • Sql Alchemy cannot run inside a transaction block
  • Instagram Authentification with python and requests
  • How can I filter out text twice in Powershell?
  • How do I make a Google Sheet script send an email when a specific cell's value changes?
  • Google Apps Script fails to generate image from EmbeddedChartBuilder
  • Android studio import problems. (Apktool)
  • C++ Is “const void” As Return Value More Const-Correct Than “void”? [duplicate]