ExcelDataValidationCollection Class

Office Open XML

Collection of ExcelDataValidation. 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.

CopyC#
// 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;

Namespace:  OfficeOpenXml.DataValidation
Assembly:  EPPlus (in EPPlus.dll) Version: 3.0.0.1 (3.0.0.1)

Syntax

C#
public class ExcelDataValidationCollection : XmlHelper, 
	IEnumerable<IExcelDataValidation>, IEnumerable
Visual Basic (Declaration)
Public Class ExcelDataValidationCollection _
	Inherits XmlHelper _
	Implements IEnumerable(Of IExcelDataValidation), IEnumerable
Visual C++
public ref class ExcelDataValidationCollection : public XmlHelper, 
	IEnumerable<IExcelDataValidation^>, IEnumerable

Inheritance Hierarchy

System..::.Object
  OfficeOpenXml..::.XmlHelper
    OfficeOpenXml.DataValidation..::.ExcelDataValidationCollection

See Also