无法从电子表格获取图表

时间:2018-09-03 15:03:12

标签: google-apps-script google-visualization spreadsheet

当我单击按钮执行脚本以发送电子邮件时,弹出对话框

  

“很抱歉,发生服务器错误。请稍候,然后重试。”

该行:var charts = sheet.getCharts();

我的脚本:

  var targetspreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = targetspreadsheet.getSheetByName('SheetName');
  var charts = sheet.getCharts();


  var chartBlobs = new Array(charts.length); 
  var emailBody = "Charts<br>";
  var emailImages = {};
  for (var i = 0; i < charts.length; i++) {
    var builder = charts[i].modify();
    builder.setOption('vAxis.format', '#');
    var newchart = builder.build();
    chartBlobs[i] = newchart.getAs('image/png');
    emailBody += "<p align='center'><img src='cid:chart" + i + "'></p>";
    emailImages["chart" + i]= chartBlobs[i];
  }

  MailApp.sendEmail({
    to: "email",
    subject: "ukol",
    htmlBody: emailBody,
    inlineImages: emailImages});

我的整个文件:https://docs.google.com/spreadsheets/d/1Qq9JhqguSuyTPmLLbI0Guoe5wcBx6n07EyRCCT_Pt8g/edit

0 个答案:

没有答案