方法一:
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);