You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "Crocker, David" <Da...@nrel.gov> on 2014/02/22 00:45:25 UTC

evaluateFormulaCell returns -1

I'm using version 9, and I am looking into the formula evaluator with the signature:

int org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator<eclipse-javadoc:%E2%98%82=SpreadSheet/war%5C/WEB-INF%5C/lib%5C/poi-ooxml-3.9-20121203.jar%3Corg.apache.poi.xssf.usermodel(XSSFFormulaEvaluator.class%E2%98%83XSSFFormulaEvaluator>.evaluateFormulaCell(Cell<eclipse-javadoc:%E2%98%82=SpreadSheet/war%5C/WEB-INF%5C/lib%5C/poi-ooxml-3.9-20121203.jar%3Corg.apache.poi.xssf.usermodel(XSSFFormulaEvaluator.class%E2%98%83XSSFFormulaEvaluator~evaluateFormulaCell~Lorg.apache.poi.ss.usermodel.Cell;%E2%98%82Cell> cell)

I evaluated a cell with the value Value 1 inside.  The method returned -1, much to my surprise.  The return values listed in the documentation are only valid values for Cell.getCellType(), i.e., CELL_TYPE_BLANK, CELL_TYPE_NUMERIC, CELL_TYPE_STRING, CELL_TYPE_FORMULA, CELL_TYPE_BOOLEAN, CELL_TYPE_ERROR.  None of these values evalute to -1.  They are zero-based.  This leads me to believe that return value of -1 means, "You can't do that!  The cell doesn't contain a formula!"

Since even I was able to figure this out, I'm not sure that it's all that important, but it sure kept me at work when I had every intention of baling early.

Comments?


David Crocker
Scientist
National Renewable Energy Laboratory
Integrated Biorefinery Research Facilities
MS 3512
16173 Denver West Parkway
Golden, CO 80401
303-384-6242
david.crocker@nrel.gov




Re: evaluateFormulaCell returns -1

Posted by Nick Burch <ap...@gagravarr.org>.
On Fri, 21 Feb 2014, Crocker, David wrote:
> I evaluated a cell with the value Value 1 inside.  The method returned 
> -1, much to my surprise.

You should check the type of the cell first, and only try to evaluate it 
if the cell type is CELL_TYPE_FORMULA.

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org