场景
SpringBoot中使用POI实现Excel导入到数据库(图文教程已实践):
https://blog.youkuaiyun.com/BADAO_LIUMANG_QIZHI/article/details/88660466
需求
在进行导入时,在导入数据库之前需要进行格式的验证,格式不正确则将单元格背景色设置为红色。
实现
主要实现代码
CellStyle style = workbook.createCellStyle();
style.setFillForegroundColor(IndexedColors.RED.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
deliveryTimeCell.setCellStyle(style);
示例代码
Workbook workbook = null;
//获取文件格式
String fileType = path.substring(path.lastIndexOf(".") + 1, path.length());
InputStream stream &#