Hi there,

 

I’m desperately need some help regarding  cell formula.  I’m using jakarta poi 2.5 final and poi-scratchpad-3.0-alpha1-20050704.jar for the formula evalution.

 

  1. First I need to get the cell formula in String.  So I base on the user guide here is my code:

HSSFCell cell = row.getCell(n);

If (cell.getCellType == HSSFCell.CELL_TYPE_FORMULA) {

            String formula = cell.getCellFormula();

}

What I’ve got is this value “NO IDEA SHARED FORMULA EXP PTG

 

The formula is very simple: =A2*B2.

 

  1. Second, I need to get the cell formula value.  So from your documentation I did the following

HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(sheet, wb);

HSSFRow row = sheet.getRow(n);

HSSFCell cell = row.getCell(n);

CellValue cellValue = evaluator.evaluate(cell); 

After this I get a NullPointerException on the last line.

 

So I change it to:

CellValue cellValue = evaluator.evaluateInCell(cell);  

Still get the NullPointerException

 

I’ve check thru the debugger the evaluator is not null, nor the cell.

 

I’ve even tried to use CellReference instead, but still the same problem.

 

I’ve attached the excel file and the sample source code.

 

I really appreciate in advance your help.

 

Thanks and God Bless

Jun Victorio

 

 

Attachment: formula.xls
Description: MS-Excel spreadsheet

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

Reply via email to