合并单元格边框样式消失

1、前置条件(合并前的单元格边框必须存在)

2、设置合并单元格样式

firstRow – Index of first row
lastRow – Index of last row (inclusive), must be equal to or larger than firstRow
firstCol – Index of first column
lastCol – Index of last column (inclusive), must be equal to or larger than firstCol

XSSFSheet sheet;
CellRangeAddress cellRangeAddress = new CellRangeAddress(firstRow , lastRow , firstCol , lastCol );
sheet.addMergedRegion(cellRangeAddress);
RegionUtil.setBorderBottom(BorderStyle.THIN, cellRangeAddress, sheet);
RegionUtil.setBorderLeft(BorderStyle.THIN, cellRangeAddress, sheet);
RegionUtil.setBorderRight(BorderStyle.THIN, cellRangeAddress, sheet);
RegionUtil.setBorderTop(BorderStyle.THIN, cellRangeAddress, sheet);

posted @ 2024-12-09 11:28  星空物语之韵  阅读(13)  评论(0编辑  收藏  举报