我想忽略此脚本的前三列(A,B和C)。最终结果将是隐藏所有具有日期标题且日期已经过去的列。下面的脚本确实隐藏了截至当前日期的所有列,但是还隐藏了包含名称的三列。有什么想法吗?
function onOpen(e) {
var sheet = e.source.getSheetByName('Sheet1'); // or .getSheets()[0]; to apply to the first sheet.
var width = sheet.getDataRange().getWidth();
var dates = sheet.getRange(1, 1, 1, width).getValues().valueOf();
var today = Date.now();
var minDiff = 1e9;
var imin = 0;
for (var i = 0; i < dates[0].length; i++) {
if (Math.abs(dates[0][i]-today) < minDiff) {
imin = i;
minDiff = Math.abs(dates[0][i]-today);
}
}
sheet.hideColumns(1, imin-1);
}