Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 将新数据追加到其他工作表中_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 将新数据追加到其他工作表中

Google apps script 将新数据追加到其他工作表中,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我正试图使用下面的代码将新范围的数据从CopySheet附加到Master5,它需要附加到Master5中的现有数据上。我尝试使用getlastrow函数,但似乎不起作用 function copysheet() { var spreadsheet = SpreadsheetApp.getActive(); spreadsheet.getRange('A4:R330').activate(); spreadsheet.setActiveSheet(spreadsheet.getShe

我正试图使用下面的代码将新范围的数据从CopySheet附加到Master5,它需要附加到Master5中的现有数据上。我尝试使用
getlastrow
函数,但似乎不起作用

function copysheet() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('A4:R330').activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Master5'), true);
  spreadsheet.getRange('B2').activate();
  spreadsheet.getLastRow()+1.activate()
  spreadsheet.getRange('CopySheet!A4:R330').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('CopySheet'), true);
  spreadsheet.getRange('4:330').activate();
  spreadsheet.getActiveRangeList().clear({contentsOnly: true, commentsOnly: true, skipFilteredRows: true});
};
电子表格。getLastRow()+1.activate()
不是有效的请求 只有一个可以

如果要激活最后一行下的单元格

  • 首先,您不仅需要选择一行,还需要选择一列
  • 在类型为
    x+y.activate()
    的请求中,该方法(在本例中为
    activate()
    )仅适用于
    y
    。为了将方法应用于
    x
    y
    ,正确的语法应该是
    (x+y).activate()
摘要:

改变

spreadsheet.getLastRow()+1.activate()

电子表格。getLastRow()+1.activate()
不是有效的请求 只有一个可以

如果要激活最后一行下的单元格

  • 首先,您不仅需要选择一行,还需要选择一列
  • 在类型为
    x+y.activate()
    的请求中,该方法(在本例中为
    activate()
    )仅适用于
    y
    。为了将方法应用于
    x
    y
    ,正确的语法应该是
    (x+y).activate()
摘要:

改变

spreadsheet.getLastRow()+1.activate()

你说的“似乎不起作用”是什么意思?你收到错误信息了吗?你说的“似乎不起作用”是什么意思?你收到错误信息了吗?
var sheet = spreadsheet.getSheetByName("Chose the name of the sheet from which you want to retrieve the last row");
var lastRow = sheet.getLastRow();
sheet.getRange(lastRow+1,1).activate();