public final class DataValidation extends Object
Constructor and Description |
---|
DataValidation()
Initializes a new instance of the
DataValidation class. |
DataValidation(CellRange... cellRanges)
Initializes a new instance of the
DataValidation class with specified cell ranges on which this data validation will be applied. |
DataValidation(ExcelWorksheet worksheet,
Iterable<String> cellReferences)
Initializes a new instance of the
DataValidation class with specified worksheet and cell references on which this data validation will be applied. |
DataValidation(ExcelWorksheet worksheet,
String... cellReferences)
Initializes a new instance of the
DataValidation class with specified worksheet and cell references on which this data validation will be applied. |
DataValidation(Iterable<CellRange> cellRanges)
Initializes a new instance of the
DataValidation class with specified cell ranges on which this data validation will be applied. |
Modifier and Type | Method and Description |
---|---|
CellRangeCollection |
getCellRanges()
Gets the ranges over which data validation is applied.
|
String |
getErrorMessage()
Gets the message text of error alert.
|
DataValidationErrorStyle |
getErrorStyle()
Gets the style of error alert used for this data validation.
|
String |
getErrorTitle()
Gets the title bar text of error alert.
|
Object |
getFormula1()
Gets the first formula in the DataValidation dropdown.
|
Object |
getFormula2()
Gets the second formula in the DataValidation dropdown.
|
String |
getInputMessage()
Gets the message text of input prompt.
|
String |
getInputMessageTitle()
Gets the title bar text of input prompt.
|
DataValidationOperator |
getOperator()
Gets the relational operator used with this data validation.
|
DataValidationType |
getType()
Gets the type of data validation.
|
boolean |
isIgnoreBlank()
Gets a value indicating whether the data validation treats empty or blank entries as
valid.
|
boolean |
isInCellDropdown()
Gets a value indicating whether to display the dropdown combo box for a
DataValidationType.LIST data validation type. |
boolean |
isShowErrorAlert()
Gets a value indicating whether to display the error alert message when an invalid
value has been entered, according to the criteria specified.
|
boolean |
isShowInputMessage()
Gets a value indicating whether to display the input prompt message.
|
void |
setErrorMessage(String errorMessage)
Sets the message text of error alert.
|
void |
setErrorStyle(DataValidationErrorStyle errorStyle)
Sets the style of error alert used for this data validation.
|
void |
setErrorTitle(String errorTitle)
Sets the title bar text of error alert.
|
void |
setFormula1(Object formula)
Sets the first formula in the DataValidation dropdown.
|
void |
setFormula2(Object formula)
Sets the second formula in the DataValidation dropdown.
|
void |
setIgnoreBlank(boolean ignoreBlank)
Sets a value indicating whether the data validation treats empty or blank entries as
valid.
|
void |
setInCellDropdown(boolean inCellDropDown)
Sets a value indicating whether to display the dropdown combo box for a
DataValidationType.LIST data validation type. |
void |
setInputMessage(String inputMessage)
Sets the message text of input prompt.
|
void |
setInputMessageTitle(String inputMessageTitle)
Sets the title bar text of input prompt.
|
void |
setOperator(DataValidationOperator operator)
Sets the relational operator used with this data validation.
|
void |
setShowErrorAlert(boolean showErrorAlert)
Sets a value indicating whether to display the error alert message when an invalid
value has been entered, according to the criteria specified.
|
void |
setShowInputMessage(boolean showInputMessage)
Sets a value indicating whether to display the input prompt message.
|
void |
setType(DataValidationType type)
Sets the type of data validation.
|
public DataValidation()
DataValidation
class.public DataValidation(CellRange... cellRanges)
DataValidation
class with specified cell ranges on which this data validation will be applied.cellRanges
- The cell ranges on which this data validation will be applied.public DataValidation(ExcelWorksheet worksheet, Iterable<String> cellReferences)
DataValidation
class with specified worksheet and cell references on which this data validation will be applied.worksheet
- The worksheet that will be used to initialize CellRange
s that will be added to the getCellRanges()
collection of this data validation.cellReferences
- The cell references from which to create CellRange
s.public DataValidation(ExcelWorksheet worksheet, String... cellReferences)
DataValidation
class with specified worksheet and cell references on which this data validation will be applied.worksheet
- The worksheet that will be used to initialize CellRange
s that will be added to the getCellRanges()
collection of this data validation.cellReferences
- The cell references from which to create CellRange
s.public DataValidation(Iterable<CellRange> cellRanges)
DataValidation
class with specified cell ranges on which this data validation will be applied.cellRanges
- The cell ranges on which this data validation will be applied.public CellRangeCollection getCellRanges()
public String getErrorMessage()
public DataValidationErrorStyle getErrorStyle()
public String getErrorTitle()
public Object getFormula1()
setFormula2(Object)
public Object getFormula2()
It used as a bounds for DataValidationOperator.BETWEEN
and DataValidationOperator.NOT_BETWEEN
relational operators only.
public String getInputMessage()
public String getInputMessageTitle()
public DataValidationOperator getOperator()
public DataValidationType getType()
public boolean isIgnoreBlank()
true
means empty entries are OK and do not violate the validation constraints.true
if empty entries are OK and do not violate the validation constraints; otherwise, false
.public boolean isInCellDropdown()
DataValidationType.LIST
data validation type.true
to display the dropdown combo box for a DataValidationType.LIST
data validation type; otherwise, false
.public boolean isShowErrorAlert()
true
to display the error alert message when an invalid
value has been entered; otherwise, false
.public boolean isShowInputMessage()
true
to display the input prompt message; otherwise, false
.public void setErrorMessage(String errorMessage)
errorMessage
- The message text of error alert.public void setErrorStyle(DataValidationErrorStyle errorStyle)
errorStyle
- The style of error alert used for this data validation.public void setErrorTitle(String errorTitle)
errorTitle
- The title bar text of error alert.public void setFormula1(Object formula)
It used as a bounds for DataValidationOperator.BETWEEN
and DataValidationOperator.NOT_BETWEEN
relational
operators, and the only formula used for other relational operators (DataValidationOperator.EQUAL
,
DataValidationOperator.NOT_EQUAL
, DataValidationOperator.LESS_THAN
, DataValidationOperator.LESS_THAN_OR_EQUAL
,
DataValidationOperator.GREATER_THAN
, DataValidationOperator.GREATER_THAN_OR_EQUAL
),
or for DataValidationType.CUSTOM
or DataValidationType.LIST
data validation type.
The content can be an instance of any type, but the following rules apply when formula is being written:
DataValidationType.WHOLE_NUMBER
or DataValidationType.TEXT_LENGTH
, and content is integral data type
(Byte
, , Short
, Integer
, Long
), formula will be saved as integral constant, else if formula is an
Excel formula or an Excel reference (String
that starts with '='), value will be saved as a formula, otherwise, it will be saved as string constant.
DataValidationType.DECIMAL
, and content is floating-point data type (Float
,
Double
, BigDecimal
), formula will be saved as floating-point constant, else if formula is an
Excel formula or an Excel reference (String
that starts with '='), value will be saved as a formula, otherwise, it will be saved as string constant.
DataValidationType.DATE
, and content is java.time.LocalDateTime
data type, formula will be saved as
date constant, else if formula is an Excel formula or an Excel reference (String
that starts with '='),
value will be saved as a formula, otherwise, it will be saved as string constant.
DataValidationType.TIME
, and content is java.time.LocalTime
data type, formula will be saved as
time constant, else if formula is an Excel formula or an Excel reference (String
that starts with '='),
value will be saved as a formula, otherwise, it will be saved as string constant.
DataValidationType.LIST
, and content is any type that implements Iterable
,
formula will be saved as list series (comma separated values), else if formula is an Excel formula or an Excel reference
(String
that starts with '='), value will be saved as a formula, otherwise, it will be saved as string constant.
DataValidationType.CUSTOM
, and formula is an Excel formula or an Excel reference
(String
that starts with '='), value will be saved as a formula, otherwise, it will be saved as string constant.
DataValidationType.NONE
, formula won't be saved.
formula
- The first formula in the DataValidation dropdown.public void setFormula2(Object formula)
It used as a bounds for DataValidationOperator.BETWEEN
and DataValidationOperator.NOT_BETWEEN
relational operators only.
For the information about the content, see setFormula1(java.lang.Object)
remarks.
formula
- The second formula in the DataValidation dropdown.public void setIgnoreBlank(boolean ignoreBlank)
true
means empty entries are OK and do not violate the validation constraints.ignoreBlank
- true
if empty entries are OK and do not violate the validation constraints; otherwise, false
.public void setInCellDropdown(boolean inCellDropDown)
DataValidationType.LIST
data validation type.inCellDropDown
- true
to display the dropdown combo box for a DataValidationType.LIST
data validation type; otherwise, false
.public void setInputMessage(String inputMessage)
inputMessage
- The message text of input prompt.public void setInputMessageTitle(String inputMessageTitle)
inputMessageTitle
- The title bar text of input prompt.public void setOperator(DataValidationOperator operator)
operator
- The relational operator used with this data validation.public void setShowErrorAlert(boolean showErrorAlert)
showErrorAlert
- true
to display the error alert message when an invalid
value has been entered; otherwise, false
.public void setShowInputMessage(boolean showInputMessage)
showInputMessage
- true
to display the input prompt message; otherwise, false
.public void setType(DataValidationType type)
type
- The type of data validation.© GemBox Ltd. — All rights reserved.