Prev: parsing dates in a string
Next: Urgent Openings: 1.GIS Web Developer, 2.Business System Analyst, Austin, TX.
From: Chase Preuninger on 28 Jun 2010 10:23 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.
From: Lew on 28 Jun 2010 13:35
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/apache/poi/ss/usermodel/ CellStyle.html> and invoke <http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/ HSSFCellStyle.html#getDataFormat()> or <http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/ HSSFCellStyle.html#getDataFormatString()> on it. You should be able to use the BuiltinFormats value <http://poi.apache.org/apidocs/org/apache/poi/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 |