Adding border to a merged region in POI XSSF workbook

后端 未结 4 966
醉话见心
醉话见心 2021-02-05 21:11

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

4条回答
  •  梦如初夏
    2021-02-05 21:33

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

提交回复
热议问题