poi给合并的单元格设置边框

//给合并的单元格设置边框
CellRangeAddress cellRangePlanNo = new CellRangeAddress(1, 1, 1, 3);
sheet.addMergedRegion(cellRangePlanNo);

setBorderForMergeCell(1, cellRangePlanNo, sheet, workBook);


//给一个范围的单元格外面设置边框

//设置最外面四周边框
CellRangeAddress brodercell = new CellRangeAddress(rowIndex-8,rowIndex-1, 0, 7);
setBorderForMergeCell(CellStyle.BORDER_MEDIUM, brodercell, sheet, workBook);




/**
     * 合并单元格设置边框
     * @param i
     * @param cellRangeTitle
     * @param sheet
     * @param workBook
     */
    private static void setBorderForMergeCell(int i, CellRangeAddress cellRangeTitle, Sheet sheet, HSSFWorkbook workBook){
        RegionUtil.setBorderBottom(i, cellRangeTitle, sheet, workBook);
        RegionUtil.setBorderLeft(i, cellRangeTitle, sheet, workBook);
        RegionUtil.setBorderRight(i, cellRangeTitle, sheet, workBook);
        RegionUtil.setBorderTop(i, cellRangeTitle, sheet, workBook);
    }

你可能感兴趣的:(poi)