Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Dates in Excel using POI

Reply
Thread Tools

Dates in Excel using POI

 
 
Chase Preuninger
Guest
Posts: n/a
 
      06-28-2010
I need to extract dates from an excel file and convert them to
strings. The only catch is that they must be formatted the EXACT same
way they were in the excel file. How can I do this. I know you can
get the data format string but I don't know how to use it.
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      06-28-2010
Chase Preuninger wrote:
> I need to extract dates from an excel [sic] file [using POI] and convert them to
> strings. *The only catch is that they must be formatted the EXACT same
> way they were in the excel [sic] file. *How can I do this. *I know you can
> get the data format string but I don't know how to use it.
>


Looks like you need to get the CellStyle of the cell
<http://poi.apache.org/apidocs/org/ap.../ss/usermodel/
CellStyle.html>
and invoke
<http://poi.apache.org/apidocs/org/ap...ssf/usermodel/
HSSFCellStyle.html#getDataFormat()>
or
<http://poi.apache.org/apidocs/org/ap...ssf/usermodel/
HSSFCellStyle.html#getDataFormatString()>
on it. You should be able to use the BuiltinFormats value
<http://poi.apache.org/apidocs/org/ap.../ss/usermodel/
BuiltinFormats.html>
to build a DateFormat
<http://java.sun.com/javase/6/docs/api/java/text/DateFormat.html>
that will do what you want.

I'm just learning POI myself.

--
Lew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CSV to excel using POI vineet.arora3 Java 0 02-10-2011 02:03 PM
Date Formats in Excel using POI Chase Preuninger Java 4 07-02-2010 11:39 PM
convert html to excel using hssf poi??? davisoski Java 0 08-16-2009 04:07 PM
Dates dates dates dates... SQL and ASP.NET David Lozzi ASP .Net 1 09-30-2005 02:18 PM
Dates! Dates! Dates! PW ASP General 4 08-09-2004 04:42 PM



Advertisments