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);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM