我有一个Google表格,其列标题中包含1/1/19-12/1/19。它们被标记为2019年1月,2019年2月等。我怎样才能打开工作表并转到当前月份并滚动它,使它成为用户看到的第一行?
这是我现在正在使用的代码:
function onOpen() {
JumpToCell();
};
function JumpToCell() {
var s = SpreadsheetApp.getActiveSpreadsheet();
// Replace "Sheet1" with the sheet name for your spreadsheet
var tab = s.getSheetByName("2019");
// replace (25,1) with the row,column where the cursor should be
tab.setActiveCell(tab.getRange(1, 720));
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getActiveSheet();
var data = sh.getDataRange().getValues();
//var today = DATE(YEAR(TODAY()), MONTH(TODAY()), 1);
var today = new Date().setHours(0,0,0,0);
var ss = SpreadsheetApp.getActiveSpreadsheet();
for(var n=0;n<data[0].length;n++){
var date =EOMONTH(TODAY(),-1)+1;
//var date = new Date(data[0][n]).setHours(0,0,0,0);
if(today==date){break};
}
n++;
sh.getRange(1,n).activate()
}