Class ExcelDataValidationCollection
Collection of Excel
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
Implements
Inherited Members
Namespace: OfficeOpenXml.DataValidation
Assembly: EPPlus.dll
Syntax
public class ExcelDataValidationCollection : IEnumerable<IExcelDataValidation>, IEnumerable
Properties
Count
Number of validations
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System. |
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.
Declaration
public bool InternalValidationEnabled { get; set; }
Property Value
Type | Description |
---|---|
System. |
Item[Int32]
Index operator, returns by 0-based index
Declaration
public ExcelDataValidation this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System. |
index |
Property Value
Type | Description |
---|---|
Excel |
Item[String]
Index operator, returns a data validation which address partly or exactly matches the searched address.
Declaration
public IExcelDataValidation this[string address] { get; }
Parameters
Type | Name | Description |
---|---|---|
System. |
address | A cell address or range |
Property Value
Type | Description |
---|---|
IExcel |
A Excel |
Methods
AddAnyValidation(String)
Adds a Excel
Declaration
public IExcelDataValidationAny AddAnyValidation(string address)
Parameters
Type | Name | Description |
---|---|---|
System. |
address | The range/address to validate |
Returns
Type | Description |
---|---|
IExcel |
AddCustomValidation(String)
Adds a Excel
Declaration
public IExcelDataValidationCustom AddCustomValidation(string address)
Parameters
Type | Name | Description |
---|---|---|
System. |
address | The range/address to validate |
Returns
Type | Description |
---|---|
IExcel |
AddDateTimeValidation(String)
Adds an IExcel
Declaration
public IExcelDataValidationDateTime AddDateTimeValidation(string address)
Parameters
Type | Name | Description |
---|---|---|
System. |
address | The range/address to validate |
Returns
Type | Description |
---|---|
IExcel |
AddDecimalValidation(String)
Addes an IExcel
Declaration
public IExcelDataValidationDecimal AddDecimalValidation(string address)
Parameters
Type | Name | Description |
---|---|---|
System. |
address | The range/address to validate |
Returns
Type | Description |
---|---|
IExcel |
AddIntegerValidation(String)
Adds an IExcel
Declaration
public IExcelDataValidationInt AddIntegerValidation(string address)
Parameters
Type | Name | Description |
---|---|---|
System. |
address | the range/address to validate |
Returns
Type | Description |
---|---|
IExcel |
AddListValidation(String)
Adds an IExcel
Declaration
public IExcelDataValidationList AddListValidation(string address)
Parameters
Type | Name | Description |
---|---|---|
System. |
address | The range/address to validate |
Returns
Type | Description |
---|---|
IExcel |
AddTextLengthValidation(String)
Adds an IExcel
Declaration
public IExcelDataValidationInt AddTextLengthValidation(string address)
Parameters
Type | Name | Description |
---|---|---|
System. |
address | The range/address to validate |
Returns
Type | Description |
---|---|
IExcel |
AddTimeValidation(String)
Adds an IExcel
Declaration
public IExcelDataValidationTime AddTimeValidation(string address)
Parameters
Type | Name | Description |
---|---|---|
System. |
address | The range/address to validate |
Returns
Type | Description |
---|---|
IExcel |
Clear()
Removes all validations from the collection.
Declaration
public void Clear()
Find(Predicate<ExcelDataValidation>)
Returns the first matching validation.
Declaration
public ExcelDataValidation Find(Predicate<ExcelDataValidation> match)
Parameters
Type | Name | Description |
---|---|---|
System. |
match |
Returns
Type | Description |
---|---|
Excel |
FindAll(Predicate<ExcelDataValidation>)
Returns all validations that matches the supplied predicate match
.
Declaration
public IEnumerable<ExcelDataValidation> FindAll(Predicate<ExcelDataValidation> match)
Parameters
Type | Name | Description |
---|---|---|
System. |
match | predicate to filter out matching validations |
Returns
Type | Description |
---|---|
System. |
ReadDataValidations(XmlReader)
Read data validation from xml via xr reader
Declaration
public void ReadDataValidations(XmlReader xr)
Parameters
Type | Name | Description |
---|---|---|
System. |
xr |
Remove(IExcelDataValidation)
Removes an Excel
Declaration
public bool Remove(IExcelDataValidation item)
Parameters
Type | Name | Description |
---|---|---|
IExcel |
item | The item to remove |
Returns
Type | Description |
---|---|
System. |
True if remove succeeds, otherwise false |
Exceptions
Type | Condition |
---|---|
System. |
if |
RemoveAll(Predicate<ExcelDataValidation>)
Removes the validations that matches the predicate
Declaration
public void RemoveAll(Predicate<ExcelDataValidation> match)
Parameters
Type | Name | Description |
---|---|---|
System. |
match |
Explicit Interface Implementations
IEnumerable<IExcelDataValidation>.GetEnumerator()
Declaration
IEnumerator<IExcelDataValidation> IEnumerable<IExcelDataValidation>.GetEnumerator()
Returns
Type | Description |
---|---|
System. |
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System. |