到目前为止,我正在尝试在xlsx列上创建日期验证:
DataValidation dataValidation = new DataValidation
{
Type = DataValidationValues.Date,
AllowBlank = false,
ShowErrorMessage = true,
ErrorTitle = "Invalid value entered",
Error = "Please enter a valid date in dd/mm/yyyy format",
SequenceOfReferences = new ListValue<StringValue> { InnerText = "A2:A10000" }
};
如果我打开xlsx文档并选择日期验证类型,则会出现以下字段:
数据:介于...之间,大于,小于 最低限度 最大
如何以编程方式设置这些?
答案 0 :(得分:0)
这为您提供了A列第2行到第10,000行的日期时间验证,使用formula1(1900年的天数)设置开始日期,使用formula2设置结束日期,formula2是开始日期之后的天数(在此case 01/01/2021)
function sendEmails() {
var sSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Area Managers");
var range = sSheet.getDataRange();
var column = 4;
var cValues = Number(sSheet.getRange(2, column, sSheet.getLastRow()).getValue());
var startRow = 2;
var numRows = sSheet.getLastRow()-1;
var dataRange = sSheet.getRange(startRow, 1, numRows, 2)
var data = dataRange.getValues();
for (i in data) {
var row = data[i];
if(row[5] >= 0) {
range = range.offset(1, 0, range.getNumRows()-1);
range.getValues().forEach( function( recipient, key, data ) {
var body = "Good day "+ recipient[0] + " you have " + recipient[4] + " Internal Audit reports outstanding.";
GmailApp.sendEmail(recipient[0] +"<"+recipient[1]+">","Outstanding Internal Audit Reports", body);
})}};
}