0

我收到错误消息:“指定的工作表必须是电子表格的一部分”。我假设“指定的工作表”是 sourceSheet ......但谁知道呢。这是想告诉我什么?更好的是,我该如何解决?我想将电子表格“File1”中的工作表插入电子表格“File2”。

谢谢

function copyTemplate() {

  var targetID="0Atn-Fxxxxt5YdF9VVxxxxxxxlZlVmeXoxxxzJuQ3c";

  // The code below will duplicate the sheet named "CellData" and insert it after 
  // the 1st sheet and call it "CellData"

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sourceSheet = ss.getSheetByName("CellData");

  var targetFile=SpreadsheetApp.openById(targetID);  

  targetFile.insertSheet("CellData", 1, {template:sourceSheet});   

}
4

1 回答 1

1
function copyTemplate() {
  SpreadsheetApp.getActiveSpreadsheet().getSheetByName('CellData')
  .copyTo(SpreadsheetApp.openById('0Atn-Fxxxxt5YdF9VVxxxxxxxlZlVmeXoxxxzJuQ3c'));
}
于 2012-12-12T04:42:08.080 回答