You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Khanh Tran <tr...@gmail.com> on 2007/01/02 09:15:41 UTC

POI formula syntax checking?

Dear experts,
I am using Formula Evaluator package to evaluate some Excel functions. When
I enter the correct formula syntax, it works fine. But when I enter
incorrect formula syntax, it does not throws any error message. I want to
retreive the error messages related to my wrong syntax.
 
 
Here is the code:
//it works fine with correct formula syntax
cell.setCellFormula("Upper(\"abc\")");
HSSFFormulaEvaluator.CellValue cellValue = evaluator.evaluate(cell);
 
//Cannot get error message
cell.setCellFormula("Upper(\"abc\", \"def\")"); //incorrect formula syntax
HSSFFormulaEvaluator.CellValue cellValue = evaluator.evaluate(cell);
assert(cellValue.cellType = CELL_TYPE_ERROR);
 
Thanks.