Cell level Data Validations

Hi

I have defined some Data validations on a particular Cell, while setting any value to the cell like this
cell.setValue(“some Value”) the API takes and sets the value to the cell irrespective of whether the validation is successful or not.

I understand that there is a way to figure out whether the value being set is satisfying the validation by calling cell.getValidationValue() which gives a boolean value, but what I am really looking for here is the value shouldn’t be set to the cell if it doesn’t satisfy the validation defined on the cell.

I am unable to find any API which does this or an API which allows me to run the validation on the value I am going to set with out having to set the value to the Cell.

@icreate.in,

Thanks for your query.

Well, you got to rely on Cell.getValidationValue() method after inserting the value into the cell for evaluation. If the Boolean attribute returns false, you should not insert the value (you may remove the value in the cell or provide some message/description to the user that the value is invalid or so.). I am afraid, you have to cope with it in your code accordingly by just adding a few extra lines/evaluation for your requirements. See the sample lines of code for your reference:
e.g
Sample code:

..............
 //Now input some value to the original template file's sheet cell for evaluation:
                    cell.putValue(value1);


                    //Check if value satisfies the Data Validation rule applied on the cell in the original template file.
                    System.out.println("Cell " + cell.getName() + ": " + "Is this a Valid Value for this Cell: " + cell.getValidationValue());
                    if (cell.getValidationValue() == false)
                    {
                        System.out.println("Cell " + cell.getName() + ": " + "This is not a valid value, so it should be eliminated from the cell");
                        cell.putValue(null);

                    }
//..........
//......Your code goes here.
//........

Hope, this helps a bit.