Class Validation
Namespace: Aspose.Cells
Assembly: Aspose.Cells.dll (25.2.0)
Represents data validation.settings.
public class Validation
Inheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
Workbook workbook = new Workbook();
ValidationCollection validations = workbook.Worksheets[0].Validations;
CellArea area = CellArea.CreateCellArea(0, 0, 1, 1);
Validation validation = validations[validations.Add(area)];
validation.Type = Aspose.Cells.ValidationType.WholeNumber;
validation.Operator = OperatorType.Between;
validation.Formula1 = "3";
validation.Formula2 = "1234";
Dim workbook as Workbook = new Workbook()
Dim validations as ValidationCollection = workbook.Worksheets(0).Validations
Dim area as CellArea = CellArea.CreateCellArea(0, 0, 1, 1);
Dim validation as Validation = validations(validations.Add(area))
validation.Type = ValidationType.WholeNumber
validation.Operator = OperatorType.Between
validation.Formula1 = "3"
validation.Formula2 = "1234"
Properties
AlertStyle
Represents the validation alert style.
public ValidationAlertType AlertStyle { get; set; }
Property Value
Areas
Gets all Aspose.Cells.CellArea which contain the data validation settings.
public CellArea[] Areas { get; }
Property Value
CellArea[]
ErrorMessage
Represents the data validation error message.
public string ErrorMessage { get; set; }
Property Value
ErrorTitle
Represents the title of the data-validation error dialog box.
public string ErrorTitle { get; set; }
Property Value
Formula1
Represents the value or expression associated with the data validation.
public string Formula1 { get; set; }
Property Value
Formula2
Represents the value or expression associated with the data validation.
public string Formula2 { get; set; }
Property Value
IgnoreBlank
Indicates whether blank values are permitted by the range data validation.
public bool IgnoreBlank { get; set; }
Property Value
InCellDropDown
Indicates whether data validation displays a drop-down list that contains acceptable values.
public bool InCellDropDown { get; set; }
Property Value
InputMessage
Represents the data validation input message.
public string InputMessage { get; set; }
Property Value
InputTitle
Represents the title of the data-validation input dialog box.
public string InputTitle { get; set; }
Property Value
Operator
Represents the operator for the data validation.
public OperatorType Operator { get; set; }
Property Value
ShowError
Indicates whether the data validation error message will be displayed whenever the user enters invalid data.
public bool ShowError { get; set; }
Property Value
ShowInput
Indicates whether the data validation input message will be displayed whenever the user selects a cell in the data validation range.
public bool ShowInput { get; set; }
Property Value
Type
Represents the data validation type.
public ValidationType Type { get; set; }
Property Value
Value1
Represents the first value associated with the data validation.
public object Value1 { get; set; }
Property Value
Value2
Represents the second value associated with the data validation.
public object Value2 { get; set; }
Property Value
Methods
AddArea(CellArea)
Applies the validation to the area.
public void AddArea(CellArea cellArea)
Parameters
cellArea
CellArea
The area.
Remarks
It is equivalent to use Aspose.Cells.Validation.AddArea(Aspose.Cells.CellArea,System.Boolean,System.Boolean) with checking intersection and edge.
AddArea(CellArea, bool, bool)
Applies the validation to the area.
public void AddArea(CellArea cellArea, bool checkIntersection, bool checkEdge)
Parameters
cellArea
CellArea
The area.
checkIntersection
bool
Whether check the intersection of given area with existing validations’ areas. If one validation has been applied in given area(or part of it), then the existing validation should be removed at first from given area. Otherwise corruption may be caused for the generated Validations. If user is sure that the added area does not intersect with any existing area, this parameter can be set as false for performance consideration.
checkEdge
bool
Whether check the edge of this validation’s applied areas. Validation’s internal settings depend on the top-left one of its applied ranges, so if given area will become the new top-left one of the applied ranges, the internal settings should be changed and rebuilt, otherwise unexpected result may be caused. If user is sure that the added area is not the top-left one, this parameter can be set as false for performance consideration.
Remarks
In this method, we will remove all old validations in given area. For the top-left one of Validation’s applied ranges, firstly its StartRow is smallest, secondly its StartColumn is the smallest one of those areas who have the same smallest StartRow.
AddAreas(CellArea[], bool, bool)
Applies the validation to given areas.
public void AddAreas(CellArea[] areas, bool checkIntersection, bool checkEdge)
Parameters
areas
CellArea[]
The areas.
checkIntersection
bool
Whether check the intersection of given area with existing validations’ areas. If one validation has been applied in given area(or part of it), then the existing validation should be removed at first from given area. Otherwise corruption may be caused for the generated Validations. If user is sure that all the added areas do not intersect with any existing area, this parameter can be set as false for performance consideration.
checkEdge
bool
Whether check the edge of this validation’s applied areas. Validation’s internal settings depend on the top-left one of its applied ranges, so if one of given areas will become the new top-left one of the applied ranges, the internal settings should be changed and rebuilt, otherwise unexpected result may be caused. If user is sure that no one of those added areas is the top-left, this parameter can be set as false for performance consideration.
Remarks
In this method, we will remove all old validations in given area. For the top-left one of Validation’s applied ranges, firstly its StartRow is smallest, secondly its StartColumn is the smallest one of those areas who have the same smallest StartRow.
Copy(Validation, CopyOptions)
Copy validation.
public void Copy(Validation source, CopyOptions copyOption)
Parameters
source
Validation
The source validation.
copyOption
CopyOptions
The copy option.
GetFormula1(bool, bool)
Gets the value or expression associated with this validation.
public string GetFormula1(bool isR1C1, bool isLocal)
Parameters
isR1C1
bool
Whether the formula needs to be formatted as R1C1.
isLocal
bool
Whether the formula needs to be formatted by locale.
Returns
The value or expression associated with this validation.
GetFormula1(bool, bool, int, int)
Gets the value or expression associated with this validation for specific cell.
public string GetFormula1(bool isR1C1, bool isLocal, int row, int column)
Parameters
isR1C1
bool
Whether the formula needs to be formatted as R1C1.
isLocal
bool
Whether the formula needs to be formatted by locale.
row
int
The row index.
column
int
The column index.
Returns
The value or expression associated with this validation.
GetFormula2(bool, bool)
Gets the value or expression associated with this validation.
public string GetFormula2(bool isR1C1, bool isLocal)
Parameters
isR1C1
bool
Whether the formula needs to be formatted as R1C1.
isLocal
bool
Whether the formula needs to be formatted by locale.
Returns
The value or expression associated with this validation.
GetFormula2(bool, bool, int, int)
Gets the value or expression associated with this validation for specific cell.
public string GetFormula2(bool isR1C1, bool isLocal, int row, int column)
Parameters
isR1C1
bool
Whether the formula needs to be formatted as R1C1.
isLocal
bool
Whether the formula needs to be formatted by locale.
row
int
The row index.
column
int
The column index.
Returns
The value or expression associated with this validation.
GetListValue(int, int)
Get the value for list of the validation for the specified cell.
public object GetListValue(int row, int column)
Parameters
row
int
The row index.
column
int
The column index.
Returns
The value to produce the list of this validation for the specified cell. If the list references to a range, then the returned value will be a Aspose.Cells.ReferredArea object; Otherwise the returned value may be null, object[], or simple object.
Remarks
Only for validation whose type is List and has been applied to given cell, otherwise null will be returned.
GetValue(int, int, bool)
Get the value of validation on the specific cell.
public object GetValue(int row, int column, bool isValue1)
Parameters
row
int
The row index.
column
int
The column index.
isValue1
bool
Indicates whether getting the first value.
Returns
RemoveACell(int, int)
Remove the validation settings in the cell.
public void RemoveACell(int row, int column)
Parameters
row
int
The row index.
column
int
The column index.
RemoveArea(CellArea)
Remove the validation settings in the range.
public void RemoveArea(CellArea cellArea)
Parameters
cellArea
CellArea
the areas where this validation settings should be removed.
RemoveAreas(CellArea[])
Removes this validation from given areas.
public void RemoveAreas(CellArea[] areas)
Parameters
areas
CellArea[]
the areas where this validation settings should be removed.
SetFormula1(string, bool, bool)
Sets the value or expression associated with this validation.
public void SetFormula1(string formula, bool isR1C1, bool isLocal)
Parameters
formula
string
The value or expression associated with this format condition.
isR1C1
bool
Whether the formula is R1C1 formula.
isLocal
bool
Whether the formula is locale formatted.
SetFormula2(string, bool, bool)
Sets the value or expression associated with this validation.
public void SetFormula2(string formula, bool isR1C1, bool isLocal)
Parameters
formula
string
The value or expression associated with this format condition.
isR1C1
bool
Whether the formula is R1C1 formula.
isLocal
bool
Whether the formula is locale formatted.