poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellis <tim.el...@emergint.com>
Subject creating a cell with date/time formatting
Date Thu, 04 May 2006 18:50:13 GMT
I have reviewed the POI documentation and numerous posts regarding this issue
and have tried every iteration presented; something is still missing, because I
cannot create a cell that shows up as Date or Time formatted when I open the
file in Excel.  I am using distribution poi-bin-2.5.1-final-20040804.zip with
JDK 1.4.2.

The following code snippet yields a new cell, position 0, in new row 'r' that
has a floating value when the file is opened in Excel; selecting the specified
Time formatting type displays the intended cell value (17:15).


//...establish workbook and sheet

Date testDate = new Date();
SimpleDateFormat fmtTime = new SimpleDateFormat("HH:mm", Locale.US);
HSSFDataFormat tfmt = wb.createDataFormat();
HSSFCellStyle cs = wb.createCellStyle();

//...establish row within sheet

c = r.createCell((short)0); //time
testDate = fmtTime.parse("17:15");


The same thing (floating value that can be correctly reformatted) happens for a
Date format of "*3/14/2001" in Excel.  If anyone has a suggestion or simply an
URL for a comprehensive set of examples, I would be much obliged.  Thanks in


To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

View raw message