使自定义日期时间格式在导出的表格中生效(原逻辑导出后的表格中双击离开后日期格式会改变)
parent
cf03781bd7
commit
dcd21854d8
|
|
@ -941,7 +941,8 @@ public class ExcelUtil<T>
|
|||
CellRangeAddress cellAddress = new CellRangeAddress(subMergedFirstRowNum, subMergedLastRowNum, column, column);
|
||||
sheet.addMergedRegion(cellAddress);
|
||||
}
|
||||
cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType())));
|
||||
CellStyle cellStyle = styles.get(StringUtils.format("data_{}_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor(), attr.cellType()));
|
||||
cell.setCellStyle(cellStyle);
|
||||
|
||||
// 用于读取对象中的属性
|
||||
Object value = getTargetValue(vo, field, attr);
|
||||
|
|
@ -950,6 +951,9 @@ public class ExcelUtil<T>
|
|||
String separator = attr.separator();
|
||||
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
|
||||
{
|
||||
// 设置日期格式样式
|
||||
cellStyle.setDataFormat(this.wb.getCreationHelper().createDataFormat().getFormat(dateFormat));
|
||||
cell.setCellStyle(cellStyle);
|
||||
cell.setCellValue(parseDateToStr(dateFormat, value));
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
|
||||
|
|
|
|||
Loading…
Reference in New Issue