public static void exportExcel(String fileName, HttpServletResponse response, Class<?> pojoClass, List<?> list, String sheet, String title, List<Integer> rowNumList) {
ExportParams params = new ExportParams();
params.setStyle(ExcelStyleUtil.class);
params.setSheetName(sheet);
params.setTitle(title);
Workbook workbook = ExcelExportUtil.exportExcel(params, pojoClass, list);
Font font = workbook.createFont();
font.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex());
font.setFontHeightInPoints((short) 11);
Sheet sheetAt = workbook.getSheetAt(0);
HSSFCellStyle style = (HSSFCellStyle) workbook.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setFont(font);
if (JudgeUtils.isNotEmpty(rowNumList)) {
int j = 0;
for (int i = 0; i < rowNumList.size(); i++) {
sheetAt.getRow(rowNumList.get(i) + j).getCell(9).setCellStyle(style);
j++;
}
}
downLoadExcel(fileName, response, workbook);
}
结合以上核心代码可以实现如下最后一列备注为红色 只供参考