台桌统计数据导出修改

This commit is contained in:
GYJ
2024-10-31 09:33:01 +08:00
parent 6ec1e0ef7d
commit b17636abbe
5 changed files with 210 additions and 199 deletions

View File

@@ -248,7 +248,18 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
Row row = sheet.createRow(i + 1);
for (int j = 0; j < keyList.size(); j++) {
Cell cell = row.createCell(j);
cell.setCellValue(map.get(keyList.get(j)) == null ? "" : map.get(keyList.get(j)).toString());
String value = map.get(keyList.get(j)) == null ? "" : map.get(keyList.get(j)).toString();
cell.setCellValue(value);
if (j == 11 && !"0".equals(value)) {
cell.setCellValue("-" + value);
setCellBackground(cell, IndexedColors.YELLOW, workbook);
}
if (j == 12 && !"0.00".equals(value)) {
cell.setCellValue("-" + value);
setCellBackground(cell, IndexedColors.YELLOW, workbook);
}
}
}
@@ -268,6 +279,13 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
}
}
private static void setCellBackground(Cell cell, IndexedColors color, Workbook workbook) {
CellStyle style = workbook.createCellStyle();
style.setFillForegroundColor(color.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cell.setCellStyle(style);
}
/**
* 输入标题到excel
*