EasyExcel 自定义颜色

easyexcel版本号:3.1.1

调用:

ExcelWriter excelWriter = EasyExcel.write("fileName")
                .registerWriteHandler(new CustomCellWriteHandler2())
                .build()

颜色配置:

public class CustomCellWriteHandler2 extends AbstractCellStyleStrategy implements CellWriteHandler {
    @Override
    protected void setHeadCellStyle(Cell cell, Head head, Integer integer) {
        XSSFCellStyle cellStyle = (XSSFCellStyle) cell.getCellStyle();
        cellStyle.setFillForegroundColor(new XSSFColor(new java.awt.Color(255, 255, 255), new DefaultIndexedColorMap()));
        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    }

    @Override
    protected void setContentCellStyle(Cell cell, Head head, Integer integer) {
    }

    @Override
    public int order() {
        return Integer.MAX_VALUE;
    }
}

你可能感兴趣的:(java,java,开发语言)