Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

POI apache Reading Excel (strange case)

 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Rancher
Posts: 42967
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
J. Insi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic