[alibaba/easyexcel]导出文件背景色整体是黑色,office打开的效果是黑色的,wps打开没事

2024-05-16 490 views
2

文件内部 文件缩率图

回答

8

版本号是

com.alibaba easyexcel 2.2.7
4

我自己定义的handler //列宽 public static SimpleColumnWidthStyleStrategy columnWidth = new SimpleColumnWidthStyleStrategy(27);

//行高
public static SimpleRowHeightStyleStrategy rowHeight = new SimpleRowHeightStyleStrategy(new Short("28"), new Short("40"));

//合并单元格
public static OnceAbsoluteMergeStrategy onceAbsoluteMergeStrategy =
        new OnceAbsoluteMergeStrategy(0, 1, 0, 1);

//单元格样式
private static List<WriteCellStyle> contentWriteCellStyleList = new ArrayList<>(Lists.newArrayList(getCustomerCellStyle()));
public static HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(new WriteCellStyle(), contentWriteCellStyleList);

private static WriteCellStyle getCustomerCellStyle() {
    WriteCellStyle cellStyle = new WriteCellStyle();
    cellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
    cellStyle.setFillForegroundColor(IndexedColors.WHITE.index);
    cellStyle.setBorderBottom(BorderStyle.THIN);
    cellStyle.setBorderLeft(BorderStyle.THIN);
    cellStyle.setBorderRight(BorderStyle.THIN);
    cellStyle.setBorderTop(BorderStyle.THIN);
    cellStyle.setBottomBorderColor(IndexedColors.BLACK1.index);
    cellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
    cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    cellStyle.setWrapped(true);
    return cellStyle;
}
0

你的自定义样式里面设置底部边框颜色的代码删掉看看,边框颜色默认就是黑色的啊. cellStyle.setBottomBorderColor(IndexedColors.BLACK1.index);