如何在电子表格的末尾移动复制的工作表?

时间:2013-09-22 13:04:53

标签: google-apps-script

如何在电子表格的末尾移动复制的工作表(列表)?

 function makecopy() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sourceSheet = ss.getSheetByName('List');
  var values = sourceSheet.copyTo(ss);
  }

1 个答案:

答案 0 :(得分:4)

moveActiveSheet是电子表格对象的方法

以下是一个例子:

function makecopy() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sourceSheet = ss.getSheetByName('List');// you can get the sheet by its name or by its index
  var copy = sourceSheet.copyTo(ss);
  Logger.log(copy.getName());// optional, just to check the copy's name
  ss.setActiveSheet(copy);// set it active
  ss.moveActiveSheet(ss.getNumSheets());// move it to the last position
  }