Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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: 43027
76
  • 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!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic