官网自定义样式:
ExcelWriter writer = ...;
// 定义单元格背景色
StyleSet style = writer.getStyleSet();
// 第二个参数表示是否也设置头部单元格背景
style.setBackgroundColor(IndexedColors.RED, false);
//设置内容字体
Font font = writer.createFont();
font.setBold(true);
font.setColor(Font.COLOR_RED);
font.setItalic(true);
//第二个参数表示是否忽略头部样式
writer.getStyleSet().setFont(font, true);
以上自定义样式是针对单元格集合的,划分为:
-
头部样式 headCellStyle
-
普通单元格样式 cellStyle
-
数字单元格样式 cellStyleForNumber
-
日期单元格样式 cellStyleForDate
但是,有时候我们只需要修改单个单元格样式,其他单元格样式采用默认样式,参考如下:
@GetMapping("downloadExampleExcel")
public Response downloadExampleExcel(HttpServletResponse response) {
logger.info("downloadExampleExcel response start。。。");