aspose file tools*
The moose likes I/O and Streams and the fly likes POI apache Reading Excel (strange case) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "POI apache Reading Excel (strange case)" Watch "POI apache Reading Excel (strange case)" New topic
Author

POI apache Reading Excel (strange case)

J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 90


Hello everyone...!
Here i have a very interesting case.

I have 1 single xls file which is saved under Ms. Excel 2003.



The idea here is that the Tarikh Cell is using a Date Value; instead of Calculation.
Thus, I put the words; "12/12/2001" ---> look at the preview above.

Very funny when I use the POI apache to read those line of cells...
It will read as calculation type. Which would return "value : 37237.0" as a value, instead of a Date that I put as before.

Which portion that I should change in my source code, to get those numbers as A STRING and not Calculation?
Correct me if I'm wrong. I guess it's the POI miss reading concept to obtain it, isn't?
Because If I try to eliminated the SWITCH Case at line 68; and strictly put the Reading


Then it will cause me an exception... because POI Detect that cells as Calculation. Is there any work around to avoid it?
I just want it to be readable in a STRING not a Calculation.

Anyway, here the Java Class that I made to read the cell inside of it is posted in the source code below.
Okay here is my source code to read the cell from Row 5th ---> Index row is 4.





Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42639
    
  65
Date cells are just a formatting Excel uses for display, not a cell type as such (which is numeric, as you've found out). If you know that a cell contains a date, then you can call getDateCellValue() to get the corresponding Date object.


Ping & DNS - my free Android networking tools app
J. Insi
Ranch Hand

Joined: Aug 11, 2010
Posts: 90
Ulf Dittmer wrote:Date cells are just a formatting Excel uses for display, not a cell type as such (which is numeric, as you've found out). If you know that a cell contains a date, then you can call getDateCellValue() to get the corresponding Date object.


exactly! thanks Ulf!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: POI apache Reading Excel (strange case)