Filter
Output: DataValidations.xlsx
public void Run()
{
var workbook = new Workbook();
var worksheet = workbook.Worksheets[0];
worksheet.Columns["A"].WidthPixels = 250;
worksheet["A1"].Value = "Whole Number between 3 and 6";
worksheet.DataValidations.AddWholeNumber("B1", DataValidationOperator.Between, 3, 6);
worksheet["A2"].Value = "Whole Number greater than or equal to 5";
worksheet.DataValidations.AddWholeNumber("B2", DataValidationOperator.GreaterThanOrEqual, 5);
worksheet["A3"].Value = "Whole Number between 2.5 and 5.5";
worksheet.DataValidations.AddDecimal("B3", DataValidationOperator.Between, 2.5, 5.5);
worksheet["A4"].Value = "Dates between 10/1/2020 and 10/20/2020";
worksheet.DataValidations.AddDate("B4", DataValidationOperator.Between,
new DateTime(2020, 10, 1), new DateTime(2020, 10, 20));
worksheet["A5"].Value = "Times between 09:00:00 and 12:00:00";
worksheet.DataValidations.AddTime("B5", DataValidationOperator.Between, new TimeSpan(9, 0, 0),
new TimeSpan(12, 0, 0));
worksheet["A6"].Value = "Text length between 5 and 10";
worksheet.DataValidations.AddTextLength("B6", DataValidationOperator.Between, 5, 10);
worksheet["A8"].Value = "Allow values ABC or DEF";
//Drop down is automatically displayed for List type validations
worksheet.DataValidations.AddList("B8", "\"ABC,DEF\"");
worksheet["A10"].Value = "Custom input message with title";
var validationB10 = worksheet.DataValidations.AddWholeNumber("B10", DataValidationOperator.Between, 3, 6);
validationB10.Range = worksheet.GetRange("B10");
validationB10.InputMessage = "Enter a number between 3 and 6";
validationB10.InputMessageTitle = "Whole Number";
workbook.SaveAs("DataValidations.xlsx");
}