Class ExcelDataValidationCollection¶
Namespace: OfficeOpenXml.DataValidation
Assembly: EPPlus.dll
Collection of [ExcelDataValidation](OfficeOpenXml.DataValidation.ExcelDataValidation.md). This class is providing the API for EPPlus data validation.
The public methods of this class (Add[...]Validation) will create a datavalidation entry in the worksheet. When this validation has been created changes to the properties will affect the workbook immediately.
Each type of validation has either a formula or a typed value/values, except for custom validation which has a formula only.
// Add a date time validation
var validation = worksheet.DataValidation.AddDateTimeValidation("A1");
// set validation properties
validation.ShowErrorMessage = true;
validation.ErrorTitle = "An invalid date was entered";
validation.Error = "The date must be between 2011-01-31 and 2011-12-31";
validation.Prompt = "Enter date here";
validation.Formula.Value = DateTime.Parse("2011-01-01");
validation.Formula2.Value = DateTime.Parse("2011-12-31");
validation.Operator = ExcelDataValidationOperator.between;
Inheritance¶
object ← ExcelDataValidationCollection
Implements¶
IEnumerable
IEnumerable<IExcelDataValidation>
Inherited Members¶
object.Equals(object?, object?)
object.Equals(object?)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object?, object?)
object.ToString()
Properties¶
Count¶
Number of validations
Property Value¶
InternalValidationEnabled¶
Epplus validates that all data validations are consistend and valid when they are added and when a workbook is saved. Since this takes some resources, it can be disabled for improve performance.
Property Value¶
this[int]¶
Index operator, returns by 0-based index
Property Value¶
this[string]¶
Index operator, returns a data validation which address partly or exactly matches the searched address.
Property Value¶
Methods¶
AddAnyValidation(string)¶
Adds a ExcelDataValidationAny to the worksheet.
Parameters¶
address string
The range/address to validate
Returns¶
AddCustomValidation(string)¶
Adds a ExcelDataValidationCustom to the worksheet.
Parameters¶
address string
The range/address to validate
Returns¶
AddDateTimeValidation(string)¶
Adds an IExcelDataValidationDateTime to the worksheet.
Parameters¶
address string
The range/address to validate
Returns¶
AddDecimalValidation(string)¶
Addes an IExcelDataValidationDecimal to the worksheet. The only accepted values are decimal values.
Parameters¶
address string
The range/address to validate
Returns¶
AddIntegerValidation(string)¶
Adds an IExcelDataValidationInt to the worksheet. Whole means that the only accepted values are integer values.
Parameters¶
address string
the range/address to validate
Returns¶
AddListValidation(string)¶
Adds an IExcelDataValidationList to the worksheet. The accepted values are defined in a list.
Parameters¶
address string
The range/address to validate
Returns¶
AddTextLengthValidation(string)¶
Adds an IExcelDataValidationInt regarding text length to the worksheet.
Parameters¶
address string
The range/address to validate
Returns¶
AddTimeValidation(string)¶
Adds an IExcelDataValidationDateTime to the worksheet.
Parameters¶
address string
The range/address to validate
Returns¶
Clear()¶
Removes all validations from the collection.
Find(Predicate<ExcelDataValidation>)¶
Returns the first matching validation.
Parameters¶
match Predicate<ExcelDataValidation>
Returns¶
FindAll(Predicate<ExcelDataValidation>)¶
Returns all validations that matches the supplied predicate match.
Parameters¶
match Predicate<ExcelDataValidation>
predicate to filter out matching validations
Returns¶
IEnumerable<ExcelDataValidation>
ReadDataValidations(XmlReader)¶
Read data validation from xml via xr reader
Parameters¶
xr XmlReader
Remove(IExcelDataValidation)¶
Removes an ExcelDataValidation from the collection.
Parameters¶
item IExcelDataValidation
The item to remove
Returns¶
True if remove succeeds, otherwise false
Exceptions¶
if item is null
RemoveAll(Predicate<ExcelDataValidation>)¶
Removes the validations that matches the predicate
Parameters¶
match Predicate<ExcelDataValidation>