Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing Date columns from Excel worksheets

 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic