Data Validation and ExcelFormula
When a data validation is loaded from a file, EPPlus normalizes its formulas for ease of use. If the content of ExcelFormula is a valid literal value, such as 1, it is exposed through Formula.Value instead. This gives you a typed value to work with rather than a formula string.
As an example, observe the following code:
using(var package = new ExcelPackage(@"c:\temp\myWorkbook.xlsx"))
{
var sheet = package.Workbook.Worksheets.Add("Example");
var validation = sheet.DataValidations.AddIntegerValidation("A1");
validation.Operator = ExcelDataValidationOperator.lessThan;
validation.Formula.ExcelFormula = "1";
SaveAndCleanup(package);
}
Using package As New ExcelPackage("c:\temp\myWorkbook.xlsx")
Dim sheet = package.Workbook.Worksheets.Add("Example")
Dim validation = sheet.DataValidations.AddIntegerValidation("A1")
validation.Operator = ExcelDataValidationOperator.lessThan
validation.Formula.ExcelFormula = "1"
SaveAndCleanup(package)
End Using
When the workbook is loaded again, the validation looks like this:
Since "1" is a valid value, EPPlus reads it as a value when the file is loaded, so you get:
excelFormula=nullvalue=1
For consistent results between the code that creates the validation and the code that reads it, we recommend assigning literal values to Formula.Value, and using ExcelFormula for cell addresses and other formulas.