main
黄海 2 years ago
parent 7b67ebcf79
commit bf537d342c

@ -582,16 +582,16 @@ public class CollectController extends Controller {
if (allow_blank && StrKit.isBlank(obj.toString())) continue;
if (column_type.equals("Integer") && !CommonUtil.isInteger(obj.toString())) {//要求整数,实际不是整数
PoiUtil.addComment(wb, cell, "要求是整数,实际数据类型不是整数!");
PoiUtil.fillColor(wb, cell, IndexedColors.YELLOW.getIndex());
PoiUtil.fillColorWithOldStyle(cell, IndexedColors.YELLOW.getIndex());
flag = false;
} else if (column_type.equals("Double") && !CommonUtil.isDouble(obj.toString())) {//要求是浮点数,实际不是浮点数
PoiUtil.addComment(wb, cell, "要求是小数,实际数据类型不是小数!");
PoiUtil.fillColor(wb, cell, IndexedColors.YELLOW.getIndex());
PoiUtil.fillColorWithOldStyle(cell, IndexedColors.YELLOW.getIndex());
flag = false;
} else if (column_type.equals("Date")) {//要求是日期,实际不是日期
if (!CommonUtil.isDate(obj.toString())) {
PoiUtil.addComment(wb, cell, "要求是日期格式,实际数据类型不是日期格式!");
PoiUtil.fillColor(wb, cell, IndexedColors.YELLOW.getIndex());
PoiUtil.fillColorWithOldStyle(cell, IndexedColors.YELLOW.getIndex());
flag = false;
}
}

@ -80,6 +80,16 @@ public class PoiUtil {
cell.setCellStyle(style);
}
public static void fillColorWithOldStyle(Cell cell, short colorIdx) {
// 创建单元格样式
CellStyle style = cell.getCellStyle();
// 设置背景颜色
style.setFillForegroundColor(colorIdx);
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
// 应用样式到单元格
cell.setCellStyle(style);
}
/**
*
*

Loading…
Cancel
Save