使用脚本将工作表标签移到最左边

PY_*_*PY_ 5 google-sheets google-apps-script

是否可以有一个小脚本来重新排列工作表标签的顺序,将当前选定的工作表标签移动到 Google 电子表格中所有标签的最左侧(开头)?

小智 6

是和否。可以通过甜蜜的名字来完成,但不能通过您正在查看的当前工作表来完成。下面是我编写的一些代码,每天将糖果移动到第一个位置。

function tab() { 

  var reportDate = new Date();
  var tabName = Utilities.formatDate(reportDate, 'MST', 'yyyy-MM-dd').toString(); 
  var tab = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(tabName);
  SpreadsheetApp.setActiveSheet(tab);
  SpreadsheetApp.getActiveSpreadsheet().moveActiveSheet(1);

} 
Run Code Online (Sandbox Code Playgroud)