我的Google服务版本为 com.google.gms:google-services:4.0.1 ,我的Google Analytics(分析)版本为16.0.1。
错误信息是:
function saveChartstoGdrive(){
//Getting chart from the current spreadsheet
var targetspreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = targetspreadsheet.getSheetByName('Sales Graph');
var charts = sheet.getCharts();
var chartBlobs=new Array(charts.length);
var filePrefix="scrlxz";
//loop through charts saving each to gdrive
for(var i=0;i<charts.length;i++){
//build each chart
var builderChart = charts[i].modify();
builderChart.setOption('width', 1400);
builderChart.setOption('height', 900);
builderChart.setOption('title', 'Updated!');
builderChart.setOption('backgroundColor', 'transparent');
var newChart =builderChart.build();
//create PNG blob of chart for writing
chartBlobs[i]= newChart.getAs('image/png');
//make sure we have the correct file and prepare for saving
var fileName = filePrefix+[i]+".png";
var fileId = DriveApp.getFilesByName(fileName).next().getId();
var contentBlob = chartBlobs[i];
//save file to ggdrive
var myVar = Drive.Files.update({mimeType: 'image/png'}, fileId, contentBlob);
}
}