1. 程式人生 > >poi設定日期格式

poi設定日期格式

方法一:

CreationHelper createHelper=wb.getCreationHelper();
CellStyle cellStyle=wb.createCellStyle(); //單元格樣式類
cellStyle.setDataFormat(createHelper.createDataFormat().getFormat("yyy-mm-dd hh:mm:ss"));
cell=row.createCell(1);
cell.setCellValue(new Date());
cell.setCellStyle(cellStyle);

 方法二:

cell=row.createCell(2); 
cell.setCellValue(Calendar.getInstance());
cell.setCellStyle(cellStyle);