我正在使用Google表格,并且在保存“目标范围的坐标超出了表格尺寸”时收到了错误消息。我检查了脚本,问题出在第15行。这是错误“ TypeError:无法调用null的方法“ getLastColumn”。(第15行,文件“代码”)”如何解决此问题?
function clear() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Form'); // Change to your Sheet tab name
sheet.getRange('D11:G35').clearContent(); // Change to the range you would like to clear
sheet.getRange('C3:C7').clearContent();
}
function save(){
var source_sheet = SpreadsheetApp.getActive().getSheetByName('Form');
var agent_name= source_sheet.getRange('C3').getValue();
var dest_sheet = SpreadsheetApp.getActive().getSheetByName(agent_name);
//add x number of new columns each save
var head_data = source_sheet.getRange('B3:E7');
var body_data = source_sheet.getRange('B9:G35'); //change this range as needed for new scoring parameters
var col = dest_sheet.getLastColumn(); + 1;
var dest_data = dest_sheet.getRange(1, col);
head_data.copyTo(dest_data, {contentsOnly: true});
dest_data = dest_sheet.getRange(6, col);
body_data.copyTo(dest_data, {contentsOnly:true});
}
function create_agent_sheets(){
var agent_sheet = SpreadsheetApp.getActive().getSheetByName("Agents");
var row = 1;
var col = 1;
while(!agent_sheet.getRange(row, col).isBlank()){
var cell = agent_sheet.getRange(row,col);
var name = cell.getValue();
SpreadsheetApp.getActive().insertSheet(name);
row++;
}
agent_sheet.activate();
}
function delete_agent_sheets(){
var agent_sheet = SpreadsheetApp.getActive().getSheetByName("Agents");
var row = 1;
var col = 1;
while(!agent_sheet.getRange(row, col).isBlank()){
var cell = agent_sheet.getRange(row,col);
var name = cell.getValue();
var sheet = SpreadsheetApp.getActive().getSheetByName(name);
SpreadsheetApp.getActive().deleteSheet(sheet);
row++;
}
agent_sheet.activate();
}
The error is preventing me from Saving the document.