public class ValidationHandle extends Object implements Handle
Using the ValidationHandle, the affected range of validations can be modified, along with many of the error messages and actual validation upon the cells. Many of these calls are very self-explanatory and can be found in the api.
Some common use cases:
// Change validation to only allow a formula ValidationHandle validator =
theSheet.getValidationHandle("A1");
validator.setValidationType(ValidationHandle.VALUE_FORMULA); // can use any VALUE static byte here.
// Validate cell is an int between the current values of cell D1 and cell D2.
ValidationHandle validator = theSheet.getValidationHandle("A1");
validator.setValidationType(ValidationHandle.VALUE_INTEGER);
validator.setTypeOperator(ValidationHandle.CONDITION_BETWEEN)// any CONDITION
static byte validator.setFirstCondition("D1"); // any valid excel formula,
omitting the '=' validator.setSecondCondition("D2");
validator.setErrorBoxText
("The value is not between the values of D1 and D2");
validator.setShowErrorMessage(true);
ValidationHandle validator = theSheet.getValidationHandle("A1");
validator.setRange("A1:Z1");
| Constructor and Description |
|---|
ValidationHandle(Dv dv)
For internal use only.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRange(String range)
Adds an additional range to the existing ranges in this validationhandle
|
static byte |
getConditionNumber(String conditionType)
Get the byte representing the condition type string passed in.
|
String |
getErrorBoxText()
Get the text from the error box.
|
String |
getErrorBoxTitle()
Get the title from the error box
|
byte |
getErrorStyle()
Return a byte representing the error style for this ValidationHandle
These map to the static final ints ERROR_* in ValidationHandle
|
String |
getFirstCondition()
Get the first condition of the validation as a string representation
|
short |
getIMEMode()
Get the IME mode for this validation
|
String |
getPromptBoxText()
Return the text in the prompt box
|
String |
getPromptBoxTitle()
Return the title in the prompt box
|
String |
getRange()
Return the range of data this ValidationHandle refers to as a string Will
not contain worksheet identifier, as ValidationHandles are specific to a
worksheet.
|
String |
getSecondCondition()
Get the second condition of the validation as a string representation
|
boolean |
getShowInputMsg()
Show prompt box if cell selected?
|
byte |
getTypeOperator()
Get the type operator of this validation as a byte.
|
byte |
getValidationType()
Get the validation type of this ValidationHandle as a byte
These bytes map to the VALUE_* static values in ValidationHandle
|
static byte |
getValueNumber(String valueType)
Get the byte representing the value type string passed in.
|
String |
getXML()
Return an xml representation of the ValidationHandle
|
boolean |
isAllowBlank()
Allow blank cells in the validation area?
|
boolean |
isInRange(String celladdy)
Determines if the ValidationHandle contains the cell address passed in
|
boolean |
isShowErrorMsg()
Show error box if invalid values entered?
|
boolean |
isStrLookup()
In list type validity the string list is explicitly given in the formula
|
boolean |
isSuppressCombo()
Suppress the drop down arrow in list type validity
|
boolean |
isValid(Object value)
Determine if the value passed in is valid for this validation
|
boolean |
isValid(Object value,
boolean throwException)
Determine if the value passed in is valid for this validation
|
void |
setAllowBlank(boolean allowBlank)
Allow blank cells in the validation area?
|
void |
setErrorBoxText(String textError)
Set the text for the error box
|
void |
setErrorBoxTitle(String textError)
Set the title for the error box
|
void |
setErrorStyle(byte errstyle)
Set the error style for this ValidationHandle record
These map to the static final ints ERROR_* from ValidationHandle
|
void |
setFirstCondition(Object firstCond)
Set the first condition of the validation
This value must conform to the Value Type of this validation or
unexpected results may occur.
|
void |
setIMEMode(short mode)
set the IME mode for this validation
|
void |
setPromptBoxText(String text)
Set the text for the prompt box
|
void |
setPromptBoxTitle(String text)
Set the title for the prompt box
|
void |
setRange(String range)
Set the range this ValidationHandle refers to.
|
void |
setSecondCondition(Object secondCond)
Set the first condition of the validation utilizing a string.
|
void |
setShowErrorMsg(boolean showErrMsg)
Set show error box if invalid values entered?
|
void |
setShowInputMsg(boolean showInputMsg)
Set show prompt box if cell selected?
|
void |
setStrLookup(boolean strLookup)
In list type validity the string list is explicitly given in the formula
|
void |
setSuppressCombo(boolean suppressCombo)
Suppress the drop down arrow in list type validity
|
void |
setTypeOperator(byte typOperator)
set the type operator of this validation as a byte.
|
void |
setValidationType(byte valtype)
Set the validation type of this ValidationHandle as a byte
These bytes map to the VALUE_* static values in ValidationHandle
|
public static final byte VALUE_ANY
public static final byte VALUE_INTEGER
public static final byte VALUE_DECIMAL
public static final byte VALUE_USER_DEFINED_LIST
public static final byte VALUE_DATE
public static final byte VALUE_TIME
public static final byte VALUE_TEXT_LENGTH
public static final byte VALUE_FORMULA
public static byte ERROR_STOP
public static byte ERROR_WARN
public static byte ERROR_INFO
public static final byte CONDITION_BETWEEN
public static final byte CONDITION_NOT_BETWEEN
public static final byte CONDITION_EQUAL
public static final byte CONDITION_NOT_EQUAL
public static final byte CONDITION_GREATER_THAN
public static final byte CONDITION_LESS_THAN
public static final byte CONDITION_GREATER_OR_EQUAL
public static final byte CONDITION_LESS_OR_EQUAL
public static short IME_MODE_NO_CONTROL
public static short IME_MODE_ON
public static short IME_MODE_OFF
public static short IME_MODE_DISABLE
public static short IME_MODE_HIRAGANA
public static short IME_MODE_KATAKANA
public static short IME_MODE_KATALANA_HALF
public static short IME_MODE_FULL_WIDTH_ALPHA
public static short IME_MODE_HALF_WIDTH_ALPHA
public static short IME_MODE_FULL_WIDTH_HANKUL
public static short IME_MODE_HALF_WIDTH_HANKUL
public static String[] CONDITIONS
public static String[] VALUE_TYPE
public ValidationHandle(Dv dv)
dv - public static byte getConditionNumber(String conditionType)
public static byte getValueNumber(String valueType)
public String getRange()
public boolean isValid(Object value) throws ValidationException
value - ValidationExceptionpublic boolean isValid(Object value, boolean throwException) throws RuntimeException
value - RuntimeExceptionpublic void setRange(String range)
range - = standard excel range without worksheet information ("A1" or
"A1:A10")public void addRange(String range)
range - public String getErrorBoxText()
public void setErrorBoxText(String textError)
textError - public String getPromptBoxText()
public void setPromptBoxText(String text)
text - public void setErrorBoxTitle(String textError)
textError - public String getErrorBoxTitle()
public String getPromptBoxTitle()
public void setPromptBoxTitle(String text)
text - public byte getErrorStyle()
public void setErrorStyle(byte errstyle)
public short getIMEMode()
public void setIMEMode(short mode)
public boolean isAllowBlank()
public void setAllowBlank(boolean allowBlank)
public String getFirstCondition()
public void setFirstCondition(Object firstCond)
firstCond - = the first condition for the validationpublic String getSecondCondition()
public void setSecondCondition(Object secondCond)
public boolean isShowErrorMsg()
public void setShowErrorMsg(boolean showErrMsg)
public boolean getShowInputMsg()
public void setShowInputMsg(boolean showInputMsg)
showInputMsg - public boolean isStrLookup()
public void setStrLookup(boolean strLookup)
strLookup - public boolean isSuppressCombo()
public void setSuppressCombo(boolean suppressCombo)
public byte getTypeOperator()
public void setTypeOperator(byte typOperator)
public byte getValidationType()
public void setValidationType(byte valtype)
public boolean isInRange(String celladdy)
range - public String getXML()
Copyright © 2002–2019 Starter Inc.. All rights reserved.