This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes Accessing Date columns from Excel worksheets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Accessing Date columns from Excel worksheets" Watch "Accessing Date columns from Excel worksheets" New topic
Author

Accessing Date columns from Excel worksheets

Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

Hello,

I am using Apache POI to read data from Excel worksheets. The defined types of cell are STRING, NUMERIC, BOOLEAN, BLANK, FORMULA and ERROR. When accessing a date column I think POI computes the date field eg. 12/12/2000 and returns a decimal value and the type of this column is NUMERIC. How do I get the exact contents as a STRING without any mathematical operation (division) being performed?

Thanks,
Rajkamal.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42355
    
  64
This sounds odd. If the cell type is text in the original file, then POI should recognize it as such (i.e, as STRING). What type of cell does Excel think it is?


Ping & DNS - my free Android networking tools app
Rajkamal Pillai
Ranch Hand

Joined: Mar 02, 2005
Posts: 443
    
    1

Sorry, I got caught up in a few things so was not checking the forum.

I finally figured it out. Sample code :



This means even if its a date column its intepreted possibly as a numeric one and then you can check further if its a date type.

Thanks,
Rajkamal.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Accessing Date columns from Excel worksheets