/** * Sets the borderRight attribute of the HSSFRegionUtil object * * @param border The new border * @param region The region that should have the border * @param workbook The workbook that the region is on. * @param sheet The sheet that the region is on. */ public static void setBorderRight(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderRight(BorderStyle.valueOf((short)border), region, sheet); }
/** * 合并单元格,可以根据设置的值来合并行和列 * * @param sheet 表对象 * @param firstRow 起始行,0开始 * @param lastRow 结束行,0开始 * @param firstColumn 起始列,0开始 * @param lastColumn 结束列,0开始 * @param cellStyle 单元格样式,只提取边框样式 * @return 合并后的单元格号 */ public static int mergingCells(Sheet sheet, int firstRow, int lastRow, int firstColumn, int lastColumn, CellStyle cellStyle) { final CellRangeAddress cellRangeAddress = new CellRangeAddress(// firstRow, // first row (0-based) lastRow, // last row (0-based) firstColumn, // first column (0-based) lastColumn // last column (0-based) ); if (null != cellStyle) { RegionUtil.setBorderTop(cellStyle.getBorderTopEnum(), cellRangeAddress, sheet); RegionUtil.setBorderRight(cellStyle.getBorderRightEnum(), cellRangeAddress, sheet); RegionUtil.setBorderBottom(cellStyle.getBorderBottomEnum(), cellRangeAddress, sheet); RegionUtil.setBorderLeft(cellStyle.getBorderLeftEnum(), cellRangeAddress, sheet); } return sheet.addMergedRegion(cellRangeAddress); }
/** * 合并单元格,可以根据设置的值来合并行和列 * * @param sheet 表对象 * @param firstRow 起始行,0开始 * @param lastRow 结束行,0开始 * @param firstColumn 起始列,0开始 * @param lastColumn 结束列,0开始 * @param cellStyle 单元格样式,只提取边框样式 * @return 合并后的单元格号 */ public static int mergingCells(Sheet sheet, int firstRow, int lastRow, int firstColumn, int lastColumn, CellStyle cellStyle) { final CellRangeAddress cellRangeAddress = new CellRangeAddress(// firstRow, // first row (0-based) lastRow, // last row (0-based) firstColumn, // first column (0-based) lastColumn // last column (0-based) ); if (null != cellStyle) { RegionUtil.setBorderTop(cellStyle.getBorderTopEnum(), cellRangeAddress, sheet); RegionUtil.setBorderRight(cellStyle.getBorderRightEnum(), cellRangeAddress, sheet); RegionUtil.setBorderBottom(cellStyle.getBorderBottomEnum(), cellRangeAddress, sheet); RegionUtil.setBorderLeft(cellStyle.getBorderLeftEnum(), cellRangeAddress, sheet); } return sheet.addMergedRegion(cellRangeAddress); }
/** * Sets the borderRight attribute of the HSSFRegionUtil object * * @param border The new border * @param region The region that should have the border * @param workbook The workbook that the region is on. * @param sheet The sheet that the region is on. */ public static void setBorderRight(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderRight(border, region, sheet, workbook); }
/** * Sets the borderRight attribute of the HSSFRegionUtil object * * @param border The new border * @param region The region that should have the border * @param workbook The workbook that the region is on. * @param sheet The sheet that the region is on. */ public static void setBorderRight(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderRight(border, region, sheet, workbook); }
/** * Sets the borderRight attribute of the HSSFRegionUtil object * * @param border The new border * @param region The region that should have the border * @param workbook The workbook that the region is on. * @param sheet The sheet that the region is on. */ public static void setBorderRight(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderRight(BorderStyle.valueOf((short)border), region, sheet); }
/** * @param context * @param sheet * @param regions */ protected void mergeCells(TableRenderContext context, Sheet sheet, List<CellRangeAddress> regions) { for (CellRangeAddress region : regions) { sheet.addMergedRegion(region); RegionUtil.setBorderTop(CellStyle.BORDER_THIN, region, sheet, workbook); RegionUtil.setBorderLeft(CellStyle.BORDER_THIN, region, sheet, workbook); RegionUtil.setBorderBottom(CellStyle.BORDER_THIN, region, sheet, workbook); RegionUtil.setBorderRight(CellStyle.BORDER_THIN, region, sheet, workbook); } }
public static void setMergeRegion(Sheet sheet, int row, int lastRow, int col, int lastCol, CellStyle cellStyle) { int i = sheet.addMergedRegion(new CellRangeAddress(row, lastRow, col, lastCol)); /** * seems like a bug */ CellRangeAddress region = sheet.getMergedRegion(sheet instanceof XSSFSheet ? i - 1 : i); RegionUtil.setBorderTop(cellStyle.getBorderTopEnum(), region, sheet); RegionUtil.setBorderLeft(cellStyle.getBorderLeftEnum(), region, sheet); RegionUtil.setBorderBottom(cellStyle.getBorderBottomEnum(), region, sheet); RegionUtil.setBorderRight(cellStyle.getBorderRightEnum(), region, sheet); }
RegionUtil.setBorderRight(1, cellRange, sheet, wb); RegionUtil.setBorderBottom(1, cellRange, sheet, wb); RegionUtil.setBorderLeft(1, cellRange, sheet, wb);
/** * 合并单元格,可以根据设置的值来合并行和列 * * @param sheet 表对象 * @param firstRow 起始行,0开始 * @param lastRow 结束行,0开始 * @param firstColumn 起始列,0开始 * @param lastColumn 结束列,0开始 * @param cellStyle 单元格样式,只提取边框样式 * @return 合并后的单元格号 */ public static int mergingCells(Sheet sheet, int firstRow, int lastRow, int firstColumn, int lastColumn, CellStyle cellStyle) { final CellRangeAddress cellRangeAddress = new CellRangeAddress(// firstRow, // first row (0-based) lastRow, // last row (0-based) firstColumn, // first column (0-based) lastColumn // last column (0-based) ); if (null != cellStyle) { RegionUtil.setBorderTop(cellStyle.getBorderTopEnum(), cellRangeAddress, sheet); RegionUtil.setBorderRight(cellStyle.getBorderRightEnum(), cellRangeAddress, sheet); RegionUtil.setBorderBottom(cellStyle.getBorderBottomEnum(), cellRangeAddress, sheet); RegionUtil.setBorderLeft(cellStyle.getBorderLeftEnum(), cellRangeAddress, sheet); } return sheet.addMergedRegion(cellRangeAddress); }