Why does the addRange function not work in Google Apps Script?

ε祈祈猫儿з 提交于 2019-12-13 02:58:05

问题


I want to import a graphical evaluation (diagram) into a new file using a macro. So the evaluation should not be inserted on a new sheet in the associated file, but a completely new file should be created, in which the graphical evaluation (in the form of a combination diagram) is then copied. The file should be either a Google Sheets or an Excel file. The combination diagram already exists and is located in a Google sheet, but it should be copied into a new file automatically with the help of a macro and the corresponding button. The code below unfortunately only inserts an empty sheet. Where is my error? The chart will depend on the data in the new Spreadsheet, so I need to have the data in the new spreadsheet using importrange. How can I modify the data range with addRange function. The code below unfortunately does not work. Like this an empty chart is inserted. Error Exception: Service error: Tables (line 7, file "Macros") (insertChart Line)

function Auswertung2() {
  var sheet = SpreadsheetApp.getActive().getSheetByName("Evaluation");
  var newSpreadsheet = SpreadsheetApp.create("new spreadsheet");
  var newSheet = newSpreadsheet.getSheets()[0];
  var chart = sheet.getCharts()[0];
  chart = chart.modify().addRange(sheet.getRange("A1:AX80")).setPosition(7, 7, 0, 0).build();
  newSheet.insertChart(chart); 
};```

来源:https://stackoverflow.com/questions/58910199/why-does-the-addrange-function-not-work-in-google-apps-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!