corelibraries-devexpress-dot-export-dot-xl-dot-xldatavalidation.md
Provides access to the collection of cell ranges to which the data validation rule is applied.
Namespace : DevExpress.Export.Xl
Assembly : DevExpress.Printing.v25.2.Core.dll
NuGet Package : DevExpress.Printing.Core
public IList<XlCellRange> Ranges { get; }
Public ReadOnly Property Ranges As IList(Of XlCellRange)
| Type | Description |
|---|---|
| IList<XlCellRange> |
A IList<XlCellRange> object representing the list of cell ranges.
|
The code sample below shows how to create a data validation rule:
// Apply data validation to cells.
// Restrict data entry in the range A2:A5 to a 5-digit number.
XlDataValidation validation = new XlDataValidation();
validation.Ranges.Add(XlCellRange.FromLTRB(0, 1, 0, 4));
validation.Type = XlDataValidationType.Custom;
validation.Criteria1 = "=AND(ISNUMBER(A2),LEN(A2)=5)";
// Add the specified rule to the worksheet collection of data validation rules.
sheet.DataValidations.Add(validation);
' Apply data validation to cells.
' Restrict data entry in the range A2:A5 to a 5-digit number.
Dim validation As New XlDataValidation()
validation.Ranges.Add(XlCellRange.FromLTRB(0, 1, 0, 4))
validation.Type = XlDataValidationType.Custom
validation.Criteria1 = "=AND(ISNUMBER(A2),LEN(A2)=5)"
' Add the specified rule to the worksheet collection of data validation rules.
sheet.DataValidations.Add(validation)
See Also