修复Excel自定义格式样式污染问题

springboot3
RuoYi 7 days ago
parent ec8e955955
commit 2d9ce89b2e

@ -1004,7 +1004,7 @@ public class ExcelUtil<T>
String separator = attr.separator();
if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value))
{
cell.getCellStyle().setDataFormat(this.wb.getCreationHelper().createDataFormat().getFormat(dateFormat));
cell.setCellStyle(createCellStyle(cell.getCellStyle(), dateFormat));
cell.setCellValue(parseDateToStr(dateFormat, value));
}
else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value))
@ -1034,6 +1034,21 @@ public class ExcelUtil<T>
return cell;
}
/**
* 使
*
* @param cellStyle
* @param format
* @return CellStyle
*/
private CellStyle createCellStyle(CellStyle cellStyle, String format)
{
CellStyle style = wb.createCellStyle();
style.cloneStyleFrom(cellStyle);
style.setDataFormat(wb.getCreationHelper().createDataFormat().getFormat(format));
return style;
}
/**
* POI XSSFSheet
*

Loading…
Cancel
Save