台桌统计数据导出修改
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user