我需要有关脚本的帮助,在此平台上使用该脚本之前我已经获得了帮助。这是基于一天和不同范围的保护脚本。
目前:每月(1-32天)是否可以设置一年中的某天(1-365)?在我的脚本中它将更好地工作。
function AddProtectionToColumn() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var range = GetRange(ss);
var protectSs = range.protect().setDescription('Protection automatique');
var me = Session.getEffectiveUser();
protectSs.addEditor(me);
protectSs.removeEditors(protectSs.getEditors());
if (protectSs.canDomainEdit()) {
protectSs.setDomainEdit(false);
}
}
function GetRange(ss){
var today = new Date().getDate();
var protections = ss.getSheets()[0].getProtections(SpreadsheetApp.ProtectionType.RANGE);
if (today == 289){ // day of the year
return ss.getRange("J1:K4");
}
else if (today == 299){
return ss.getRange("J5:K10");
}
}
感谢您的帮助!
得到一年中的一天
parseInt(Utilities.formatDate(new Date(),Session.getScriptTimeZone(), "D"));
因此,在您的代码中:
function GetRange(ss){
var today = parseInt(Utilities.formatDate(new Date(),Session.getScriptTimeZone(), "D"));
var protections = ss.getSheets()[0].getProtections(SpreadsheetApp.ProtectionType.RANGE);
if (today == 289){ // day of the year
return ss.getRange("J1:K4");
}
else if (today == 299){
return ss.getRange("J5:K10");
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句