I'm using apache poi 3.7 and I need to put border to a range of cells or merged region.
how can I to apply border to a merged region when the sheet and workbook type is XSSF. In HSSF type I use RegionUtil-/HSSFRegionutil, but if use the first object (Regionutil) in XSSF type its doesn't works and puts a black background color to the range of cells.
Regionutil ussually works with CellRangeAddress and i don't find information about this trouble. I don't know if the CellRangeAddres causes this.
@Jesanagua just saved my life, I just had to change a bit to match 3.17.
private void setBordersToMergedCells(HSSFSheet sheet) {
int numMerged = sheet.getNumMergedRegions();
for (int i = 0; i < numMerged; i++) {
CellRangeAddress mergedRegions = sheet.getMergedRegion(i);
RegionUtil.setBorderLeft(BorderStyle.THIN, mergedRegions, sheet);
RegionUtil.setBorderRight(BorderStyle.THIN, mergedRegions, sheet);
RegionUtil.setBorderTop(BorderStyle.THIN, mergedRegions, sheet);
RegionUtil.setBorderBottom(BorderStyle.THIN, mergedRegions, sheet);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With