在日期打开Goog​​le电子表格 [英] Open google spreadsheet at date

查看:71
本文介绍了在日期打开Goog​​le电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Google电子表格。在第1行的A列中,我使用了 vastzetten(荷兰语)。我已阻止的第一列和第一行。当我使用光标时,我可以更改日期,而其余的工作表在该块之后消失。 (查看图像)。当我启动工作表时,有没有办法选择日期,然后将工作表的其余部分移到标题栏之后?我希望有人知道我的意思。

I have created a google spreadsheet. On the column A in row 1 I have used "vastzetten" (that's in dutch). The first column and row I have blocked. When I go with the cursor I can change the date and the rest of the sheet dissapeared after the block. (Look the images). Is there a way when I start the sheet it selects the date of the day then moves the rest of the sheet after the titleblock? I hope that somebody knows what I mean.

推荐答案

您可以使用可安装的触发器来隐藏列和/或激活与当前日期相对应的范围。

You could use an installable trigger to hide columns and/or to activate the range corresponding to the current date.

有关如何设置的说明可安装的触发器,请参见 https://developers.google.com/apps-script/guides / triggers / installable

For instructions on how to set an installable trigger see https://developers.google.com/apps-script/guides/triggers/installable

以下代码假定列标题是日期类型的值。如果找到当前日期,则左侧的列将被隐藏,并且相应标题下方的单元格将被激活。

The following code assumes that the column headers are values of date type. If the current date is found, then the columns at the left will be hidden and the the cell below the corresponding header will be activated.

function myFunction(){
  var ss = SpreadsheetApp.getActive();
  var sheet = ss.getSheets()[0];
  var tz = ss.getSpreadsheetTimeZone();
  var today = Utilities.formatDate(new Date(), tz, 'YYYY-MM-dd')
  var data = sheet.getDataRange().getValues();
  var headers = data[0];
  for(var i = 0;i<= headers.length;i++){
    if(headers[i] instanceof Date){
      if(today == Utilities.formatDate(headers[i], tz, 'YYYY-MM-dd')){
        sheet.hideColumns(2,i-1);
        sheet.getRange(2, i+1).activate();
        break;
      }
    }
  }
}

这篇关于在日期打开Goog​​le电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆