public class Validation
extends java.lang.Object
Example
Workbook workbook = new Workbook();
ValidationCollection validations = workbook.getWorksheets().get(0).getValidations();
CellArea area = CellArea.createCellArea(0, 0, 1, 1);
Validation validation = validations.get(validations.add(area));
validation.setType(com.aspose.cells.ValidationType.WHOLE_NUMBER);
validation.setOperator(OperatorType.BETWEEN);
validation.setFormula1("3");
validation.setFormula2("1234");
| Modifier and Type | Method and Description |
|---|---|
void |
addArea(CellArea cellArea)
Applies the validation to the area.
|
void |
addArea(CellArea cellArea,
boolean checkIntersection,
boolean checkEdge)
Applies the validation to the area.
|
void |
addAreas(CellArea[] areas,
boolean checkIntersection,
boolean checkEdge)
Applies the validation to given areas.
|
void |
copy(Validation source,
CopyOptions copyOption)
Copy validation.
|
int |
getAlertStyle()
Represents the validation alert style.
|
CellArea[] |
getAreas()
Gets all
CellArea which contain the data validation settings. |
java.lang.String |
getErrorMessage()
Represents the data validation error message.
|
java.lang.String |
getErrorTitle()
Represents the title of the data-validation error dialog box.
|
java.lang.String |
getFormula1()
Represents the value or expression associated with the data validation.
|
java.lang.String |
getFormula1(boolean isR1C1,
boolean isLocal)
Gets the value or expression associated with this validation.
|
java.lang.String |
getFormula1(boolean isR1C1,
boolean isLocal,
int row,
int column)
Gets the value or expression associated with this validation for specific cell.
|
java.lang.String |
getFormula2()
Represents the value or expression associated with the data validation.
|
java.lang.String |
getFormula2(boolean isR1C1,
boolean isLocal)
Gets the value or expression associated with this validation.
|
java.lang.String |
getFormula2(boolean isR1C1,
boolean isLocal,
int row,
int column)
Gets the value or expression associated with this validation for specific cell.
|
boolean |
getIgnoreBlank()
Indicates whether blank values are permitted by the range data validation.
|
boolean |
getInCellDropDown()
Indicates whether data validation displays a drop-down list that contains acceptable values.
|
java.lang.String |
getInputMessage()
Represents the data validation input message.
|
java.lang.String |
getInputTitle()
Represents the title of the data-validation input dialog box.
|
java.lang.Object |
getListValue(int row,
int column)
Get the value for list of the validation for the specified cell.
|
int |
getOperator()
Represents the operator for the data validation.
|
boolean |
getShowError()
Indicates whether the data validation error message will be displayed whenever the user enters invalid data.
|
boolean |
getShowInput()
Indicates whether the data validation input message will be displayed whenever the user selects a cell in the data validation range.
|
int |
getType()
Represents the data validation type.
|
java.lang.Object |
getValue(int row,
int column,
boolean isValue1)
Get the value of validation on the specific cell.
|
java.lang.Object |
getValue1()
Represents the first value associated with the data validation.
|
java.lang.Object |
getValue2()
Represents the second value associated with the data validation.
|
void |
removeACell(int row,
int column)
Remove the validation settings in the cell.
|
void |
removeArea(CellArea cellArea)
Remove the validation settings in the range.
|
void |
removeAreas(CellArea[] areas)
Removes this validation from given areas.
|
void |
setAlertStyle(int value)
Represents the validation alert style.
|
void |
setErrorMessage(java.lang.String value)
Represents the data validation error message.
|
void |
setErrorTitle(java.lang.String value)
Represents the title of the data-validation error dialog box.
|
void |
setFormula1(java.lang.String value)
Represents the value or expression associated with the data validation.
|
void |
setFormula1(java.lang.String formula,
boolean isR1C1,
boolean isLocal)
Sets the value or expression associated with this validation.
|
void |
setFormula2(java.lang.String value)
Represents the value or expression associated with the data validation.
|
void |
setFormula2(java.lang.String formula,
boolean isR1C1,
boolean isLocal)
Sets the value or expression associated with this validation.
|
void |
setIgnoreBlank(boolean value)
Indicates whether blank values are permitted by the range data validation.
|
void |
setInCellDropDown(boolean value)
Indicates whether data validation displays a drop-down list that contains acceptable values.
|
void |
setInputMessage(java.lang.String value)
Represents the data validation input message.
|
void |
setInputTitle(java.lang.String value)
Represents the title of the data-validation input dialog box.
|
void |
setOperator(int value)
Represents the operator for the data validation.
|
void |
setShowError(boolean value)
Indicates whether the data validation error message will be displayed whenever the user enters invalid data.
|
void |
setShowInput(boolean value)
Indicates whether the data validation input message will be displayed whenever the user selects a cell in the data validation range.
|
void |
setType(int value)
Represents the data validation type.
|
void |
setValue1(java.lang.Object value)
Represents the first value associated with the data validation.
|
void |
setValue2(java.lang.Object value)
Represents the second value associated with the data validation.
|
public int getOperator()
See OperatorType.
public void setOperator(int value)
See OperatorType.
public int getAlertStyle()
See ValidationAlertType.
public void setAlertStyle(int value)
See ValidationAlertType.
public int getType()
See ValidationType.
public void setType(int value)
See ValidationType.
public java.lang.String getInputMessage()
public void setInputMessage(java.lang.String value)
public java.lang.String getInputTitle()
public void setInputTitle(java.lang.String value)
public java.lang.String getErrorMessage()
public void setErrorMessage(java.lang.String value)
public java.lang.String getErrorTitle()
public void setErrorTitle(java.lang.String value)
public boolean getShowInput()
public void setShowInput(boolean value)
public boolean getShowError()
public void setShowError(boolean value)
public boolean getIgnoreBlank()
public void setIgnoreBlank(boolean value)
public java.lang.String getFormula1(boolean isR1C1,
boolean isLocal)
isR1C1 - Whether the formula needs to be formatted as R1C1.isLocal - Whether the formula needs to be formatted by locale.public java.lang.String getFormula2(boolean isR1C1,
boolean isLocal)
isR1C1 - Whether the formula needs to be formatted as R1C1.isLocal - Whether the formula needs to be formatted by locale.public java.lang.String getFormula1(boolean isR1C1,
boolean isLocal,
int row,
int column)
isR1C1 - Whether the formula needs to be formatted as R1C1.isLocal - Whether the formula needs to be formatted by locale.row - The row index.column - The column index.public java.lang.String getFormula2(boolean isR1C1,
boolean isLocal,
int row,
int column)
isR1C1 - Whether the formula needs to be formatted as R1C1.isLocal - Whether the formula needs to be formatted by locale.row - The row index.column - The column index.public void setFormula1(java.lang.String formula,
boolean isR1C1,
boolean isLocal)
formula - The value or expression associated with this format condition.isR1C1 - Whether the formula is R1C1 formula.isLocal - Whether the formula is locale formatted.public void setFormula2(java.lang.String formula,
boolean isR1C1,
boolean isLocal)
formula - The value or expression associated with this format condition.isR1C1 - Whether the formula is R1C1 formula.isLocal - Whether the formula is locale formatted.public java.lang.String getFormula1()
public void setFormula1(java.lang.String value)
public java.lang.String getFormula2()
public void setFormula2(java.lang.String value)
public java.lang.Object getListValue(int row,
int column)
Remarks
Only for validation whose type is List and has been applied to given cell, otherwise null will be returned.row - The row index.column - The column index.ReferredArea object;
Otherwise the returned value may be null, object[], or simple object.public java.lang.Object getValue1()
public void setValue1(java.lang.Object value)
public java.lang.Object getValue2()
public void setValue2(java.lang.Object value)
public java.lang.Object getValue(int row,
int column,
boolean isValue1)
row - The row index.column - The column index.isValue1 - Indicates whether getting the first value.public boolean getInCellDropDown()
public void setInCellDropDown(boolean value)
public void addArea(CellArea cellArea)
Remarks
It is equivalent to useaddArea(CellArea,boolean,boolean)
with checking intersection and edge.cellArea - The area.public void addArea(CellArea cellArea, boolean checkIntersection, boolean checkEdge)
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.cellArea - The area.checkIntersection - 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 - 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.public void addAreas(CellArea[] areas, boolean checkIntersection, boolean checkEdge)
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.areas - The areas.checkIntersection - 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 - 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.public void removeArea(CellArea cellArea)
cellArea - the areas where this validation settings should be removed.public void removeAreas(CellArea[] areas)
areas - the areas where this validation settings should be removed.public void removeACell(int row,
int column)
row - The row index.column - The column index.public void copy(Validation source, CopyOptions copyOption)
source - The source validation.copyOption - The copy option.See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.