边框不适用于合并的单元格,但仅适用于第一个单元格

我正在尝试合并2个单元格,并在其周围应用边框样式。 合并工作正常,但边界只适用于第一个单元格。 这是我的代码片段。 任何人都可以帮助我(注意:这不是完整的代码,在高层次上,我创build了一个样式,应用于单元格,然后合并单元格,应用颜色后,边框不可见,所以我添加了setBorder .. code使其可见,但它只适用于合并单元格的第一个单元格。

CellStyle newStyle = wb.createCellStyle(); cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); cellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); cell.setCellStyle(cellStyle); sheet.addMergedRegion(new CellRangeAddress(i, i, 0, 19));