Google表:更改颜色/突出显示主动电子表格选项卡



是否有一种方法可以自动更改Google表格中的活动表的颜色,而不仅仅是将表格名称更改为green?

刚刚基于Google在类文档中提供的.setTabColor()脚本示例编写。

function onEdit() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheets = ss.getSheets();
  var numSheets = ss.getNumSheets();
  var active = ss.getActiveSheet();
  var tabCol = active.getTabColor();
  if (tabCol == null) {
    //loop through all sheets and clear tab colour.
    for (var i = 0; i < numSheets; i++) {
      sheets[i].setTabColor(null);
    }
    active.setTabColor("ff0000"); //change ff0000 to whatever colour hex value you'd like. 
  }
}

基本上,此脚本将检查您当前正在编辑的表是否分配了颜色,如果这样做,它将无能为力,如果不这样做,则会给它颜色。我提供了一个基本的循环,可以通过所有床单并清除它们的颜色,以便只有您当前编辑的表格才会分配颜色。

最新更新