Wie kann man mit POI in Excel ein Datum setzen

Hallo zusammen,

ich hab da mal wieder ein Problem. Mein Javaprogramm will eine Exceldatei mit Hilfe von POI befüllen.
Bei numerischen und alphanumerischen Inhalten habe ich dabei auch kein problem (cell.setCellType(Cell.CELL_TYPE_STRING)bzw. cell.setCellType(Cell.CELL_TYPE_NUMERIC)). Nun habe ich jedoch auch einige Datumswerte, die auch als solche im Excel definiert sein sollen. Kann mir jemand sagen, wie ich in diesem Fall den Celltype definieren muss?

Danke schon mal!

Sandra

Hallo Sandra,

das scheint genz einfach zu sein ^^ (man muss nur wissen wo es steht :wink:)

Also schau dir die Seiten von Appache mal genauer an (http://poi.apache.org)
Damit du aber für dein Problem net so lange suchen musst ^^

source:

http://poi.apache.org/spreadsheet/quick-guide.html#C…

Zitat der Quelle:

// we style the second cell as a date (and time). It is important to
// create a new cell style from the workbook otherwise you can end up
// modifying the built in style and effecting not only this cell but other cells.
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setDataFormat(
createHelper.createDataFormat().getFormat(„m/d/yy h:mm“));
cell = row.createCell(1);
cell.setCellValue(new Date());
cell.setCellStyle(cellStyle);