Java 导出 excel ,要求日期单元格能按照年月日筛选。如下图。
XSSFDataFormat df = workbook.createDataFormat();
XSSFCellStyle hssfCellStyleDate = wb.createCellStyle();
String dateFormat = "yyyy-MM-dd";
hssfCellStyleDate.setDataFormat(df.getFormat(dateFormat));
SimpleDateFormat format = new SimpleDateFormat(dateFormat);
cell.setCellValue(format.parse(cellValue.toString()));
cell.setCellStyle(hssfCellStyleDate);