POI合并单元格后边框显示问题
最近在做导出Excel报表业务. 牵扯到一个复杂表头…
首先我分成3层来为表头数据装配样式. 但是两大行中因为牵扯到一个合并问题,没有附上边框, 之后也百度了前辈们总结的经验,
附上代码:
//合并单元格添加边框 解决合并单元格后没有边框
CellRangeAddress cellAddrss = new CellRangeAddress(startrow, overrow, startcol, overcol);
setBorderStyle(BorderStyle.THIN, cellAddrss, sheet);
startrow: 起始行
overrow: 结束行
startcol: 起始列
overcol: 结束列
//合并单元格后添加边框
public static void setBorderStyle(BorderStyle borderStyle, CellRangeAddress region, SXSSFSheet sheet) {
RegionUtil.setBorderBottom(borderStyle, region, sheet); //下边框
RegionUtil.setBorderLeft(borderStyle, region, sheet); //左边框
RegionUtil.setBorderRight(borderStyle, region, sheet); //右边框
RegionUtil.setBorderTop(borderStyle, region, sheet); //上边框
}
附上前辈们总结的连接
详见链接:https://blog.csdn.net/AlcedoAtthis/article/details/88892497;
https://www.cnblogs.com/mr-wuxiansheng/p/7911521.html