Bug 33156 - Excel does not recognize POI created cells as numbers
Summary: Excel does not recognize POI created cells as numbers
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.5-FINAL
Hardware: PC Windows 2000
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2005-01-18 21:02 UTC by Tammy Walters
Modified: 2005-01-19 07:57 UTC (History)
0 users

Example spreadsheet (14.50 KB, application/octet-stream)
2005-01-18 21:04 UTC, Tammy Walters

Note You need to log in before you can comment on or make changes to this bug.
Description Tammy Walters 2005-01-18 21:02:11 UTC
I created a spreadsheet using POI.  The cells were formatted with a number 
format.  After opening up the created spreadsheet, I tried to sum one of the 
cumeric columns.  The result of that sum is always 0.  I have manually used 
excel to change the formatting of the column to be a number format, but it does 
not change the sum.  The only thing I can do to get the sum to work is to 
manually re-type the numbers in the spreadsheet.
Comment 1 Tammy Walters 2005-01-18 21:04:29 UTC
Created attachment 14041 [details]
Example spreadsheet

Note that the final two columns in the EODStats sheet have a sum formula at the
bottom of the column.  The Qty Problems sum is 0, and the Waiting for Recpt sum
is 8 because I manually retyped the 8 in the column.
Comment 2 Tammy Walters 2005-01-18 21:08:12 UTC
Code used to set the cell type of numeric:

		cellStyle = wb.createCellStyle();
Comment 3 Tammy Walters 2005-01-19 16:37:37 UTC
I found the root cause.  Even though I set the cell type as numeric, when I set 
the cell value I passed in a String instead of a double.  Changing my code to 
test for the string being a number and setting the value accordingly has fixed 
the error in the spreadsheet.
Comment 4 Avik Sengupta 2005-01-19 16:57:33 UTC
Indeed.  Actually, in the usual case ,you dont have to set cell type.. its
automatically set based on the value you pass in. Maybe a FAQ?