EasyExcel设置单元格边框

/**
    * 单元格边框
    * @return {@link HorizontalCellStyleStrategy}
    * @date 2021/10/26 13:22
    * @author <a href="">fxsen</a> <br/>
    * @version 1.0.0 <br/>
    **/
    public static HorizontalCellStyleStrategy cellBorder(){
        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
        contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);
        contentWriteCellStyle.setBorderTop(BorderStyle.THIN);
        contentWriteCellStyle.setBorderRight(BorderStyle.THIN);
        contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);
        return new HorizontalCellStyleStrategy(contentWriteCellStyle, contentWriteCellStyle);
    }

调用示例

EasyExcel.write(response.getOutputStream())
        .head(ExcelHeaderUtil.getColumnName(columnName))
        .registerWriteHandler(ExcelHeaderUtil.cellBorder())
        .registerWriteHandler(new EasyExcelCustomCellWriteHandler())
        .sheet("栏目数据").doWrite(list);
posted @ 2021-10-26 19:23  fxsen  阅读(2701)  评论(0编辑  收藏  举报