diff --git a/blade-common/src/main/java/org/springblade/common/excel/ImportFailureExcelUtil.java b/blade-common/src/main/java/org/springblade/common/excel/ImportFailureExcelUtil.java index e297cb5..6b0ad40 100644 --- a/blade-common/src/main/java/org/springblade/common/excel/ImportFailureExcelUtil.java +++ b/blade-common/src/main/java/org/springblade/common/excel/ImportFailureExcelUtil.java @@ -35,7 +35,6 @@ import cn.idev.excel.write.metadata.holder.WriteTableHolder; import jakarta.servlet.http.HttpServletResponse; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.FillPatternType; import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.Workbook; @@ -255,7 +254,6 @@ public class ImportFailureExcelUtil { private final List> rows; private final Map> redColumnsByRow = new HashMap<>(); private final Map redStyleCache = new HashMap<>(); - private final Map redFillStyleCache = new HashMap<>(); private final Map noWrapStyleCache = new HashMap<>(); private final Map columnWidthCache = new HashMap<>(); @@ -292,7 +290,7 @@ public class ImportFailureExcelUtil { return; } if (shouldMarkRed(relativeRowIndex, cell.getColumnIndex())) { - markRed(cell, isBlankValue(rows.get(relativeRowIndex), cell.getColumnIndex())); + markRed(cell); } } @@ -359,24 +357,15 @@ public class ImportFailureExcelUtil { return redColumns != null && redColumns.contains(columnIndex); } - private boolean isBlankValue(List row, int columnIndex) { - if (columnIndex < 0 || columnIndex >= row.size()) { - return true; - } - Object value = row.get(columnIndex); - return value == null || String.valueOf(value).isBlank(); - } - /** * 标红单元格 *

- * 单元格为空时只改字体颜色屏幕上什么也看不到(「必填项为空」正是这种情况), - * 因此对空单元格额外加浅红底纹,保证用户能定位到是哪一列出错。 + * 统一只改字体颜色,不加底纹;空单元格的红色字体在屏幕上不可见, + * 这类错误依靠失败原因列的文字定位。 */ - private void markRed(Cell cell, boolean blankValue) { + private void markRed(Cell cell) { CellStyle currentStyle = cell.getCellStyle(); - Map styleCache = blankValue ? redFillStyleCache : redStyleCache; - CellStyle redStyle = styleCache.computeIfAbsent(currentStyle.getIndex(), styleIndex -> { + CellStyle redStyle = redStyleCache.computeIfAbsent(currentStyle.getIndex(), styleIndex -> { Workbook workbook = cell.getSheet().getWorkbook(); CellStyle newStyle = workbook.createCellStyle(); newStyle.cloneStyleFrom(currentStyle); @@ -384,10 +373,6 @@ public class ImportFailureExcelUtil { font.setColor(IndexedColors.RED.getIndex()); newStyle.setFont(font); newStyle.setWrapText(true); - if (blankValue) { - newStyle.setFillForegroundColor(IndexedColors.ROSE.getIndex()); - newStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); - } return newStyle; }); cell.setCellStyle(redStyle);