Bug 41235 - Wrong formula value on new cell!
Summary: Wrong formula value on new cell!
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-dev
Hardware: PC Windows XP
: P1 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-22 19:04 UTC by Khanh Tran
Modified: 2007-01-16 02:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Khanh Tran 2006-12-22 19:04:09 UTC
Here's the code:

HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
HSSFRow row = sheet.createRow(0);
HSSFCell cell = row.createCell( (short) 0);
cell.setCellFormula("SUM(1,2)");
double num = cell.getNumericCellValue();
//0.0 will be printed out
System.out.println(num);

It returned 0.0, instead of 3.
Comment 1 Avik Sengupta 2007-01-16 02:05:15 UTC
POI does NOT automatically calculate formulas. POI is essentially a file format
processor, not a functional replacement for excel.

To evaluate formulas, you'll have to open the sheet in Excel. For simpler
formulas, you can use the Formula Evaluator in poi's scratchpad.
http://jakarta.apache.org/poi/hssf/eval.html