• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

POI apache Reading Excel (strange case)

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.





 
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic