【问题标题】:How do I make a copy of a google sheet tab and rename it如何复制 google 工作表标签并将其重命名
【发布时间】:2023-01-01 23:44:14
【问题描述】:

这是我的代码,我试图让 oldmonthtab 复制自己并将自己命名为 newmonthname,但我只是想不出如何让最后一部分工作。

  var oldMonthName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("X2").getRange("U4").getValue();//name for the old month, formula in X2
  var newMonthName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("X2").getRange("U3").getValue();//name for new month, formula in X2
  var oldMonthTab = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(oldMonthName);//old month tab, used to be able to hide it
  
  var destination = SpreadsheetApp.openById('1lQ10rgciG5WiUQ0uVQc1E7r7Qwd6hOkZQSaH');//chooses this spreadsheet, the ID should come from the URL of the sheet it will be copied to.
  oldMonthTab.copyTo(destination).setname(newMonthTab);//makes a copy of old month and sets the name to new month```
 

【问题讨论】:

    标签: google-apps-script google-sheets


    【解决方案1】:

    变量newMonthTab 未定义。用这个:

      oldMonthTab.copyTo(destination).setname(newMonthName);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-12
      • 2021-08-23
      • 1970-01-01
      • 2015-08-28
      • 2023-03-29
      • 2020-12-29
      相关资源
      最近更新 更多