You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Christian Gosch <c....@inovex.de> on 2005/11/15 17:36:00 UTC
POI 2.5.1 final: Date value formatting to 'DD.MM.YYYY'
Hi,
I cannot successfully format a cell with "DD.MM.YYYY" nor with any other
date format. All I get is "#.##0" number format for the cells. How can I
achieve "DD.MM.YYYY" formatting?
POI version: 2.5.1 final (this is fairly old, but there does not seem to be
any newer "final" version :-( )
Code sample:
// font for rows:
HSSFCellStyle borderdFormat = workbook.createCellStyle();
// borderdFormat.setBorderTop( HSSFCellStyle.BORDER_HAIR); // should
be...
// borderdFormat.setBorderBottom( HSSFCellStyle.BORDER_HAIR); //
should be...
borderdFormat.setBorderTop( HSSFCellStyle.BORDER_DOTTED); // ...but
is not (!)
borderdFormat.setBorderBottom( HSSFCellStyle.BORDER_DOTTED); //
...but is not (!)
[...]
else if (data instanceof Date) {
// data is of type Date
log.debug("XLS-DL: Date: xlsZeile = " + xlsZeile + " spalte
= " + spalte + " value = " + data + " class = " + data.getClass());
borderdFormat.setDataFormat((short)15);
label.setCellValue( ((Date)data));
label.setCellStyle(borderdFormat);
sdata = data.toString();
}
The log.debug(...) output is like:
XLS-DL: Date: xlsZeile = 1 spalte = 10 value = 1944-04-10 01:00:00.0 class =
class java.sql.Timestamp
The resulting cell value display in Excel2000 (deDE in W2KSP4 deDE) is:
16.172
which would be the result of formatting "10.4.1944" or "Apr. 10, 1944" with
"#.##0".
What am I doing wrong?
regards,
--
Dipl.-Inform. Christian Gosch
Systems Development
inovex GmbH
Karlsruher Strasse 71
D-75179 Pforzheim
Tel.: +49 (0)72 31 - 31 91 - 85
Fax: +49 (0)72 31 - 31 91 - 91
mailto:c.gosch@inovex.de
http://www.inovex.de