/** * 合并单元格,可以根据设置的值来合并行和列 * * @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 bottomBorderColor attribute of the HSSFRegionUtil object * * @param color The color of the 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 setBottomBorderColor(int color, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBottomBorderColor(color, region, sheet); }
/** * Sets the leftBorderColor attribute of the HSSFRegionUtil object * * @param color The color of the 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 setLeftBorderColor(int color, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setLeftBorderColor(color, region, sheet); }
/** * Sets the borderBottom 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 setBorderBottom(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderBottom(BorderStyle.valueOf((short)border), region, sheet); }
/** * Sets the borderBottom 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 setBorderTop(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderTop(BorderStyle.valueOf((short)border), region, sheet); }
/** * 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); }
/** * Sets the left border for a region of cells by manipulating the cell style * of the individual cells on the left * * @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 setBorderLeft(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderLeft(BorderStyle.valueOf((short)border), region, sheet); }
/** * Sets the rightBorderColor attribute of the HSSFRegionUtil object * * @param color The color of the 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 setRightBorderColor(int color, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setRightBorderColor(color, region, sheet); }
/** * Sets the topBorderColor attribute of the HSSFRegionUtil object * * @param color The color of the 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 setTopBorderColor(int color, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setTopBorderColor(color, region, sheet); } }
/** * Sets the borderBottom 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 setBorderBottom(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderBottom(border, region, sheet, workbook); }
/** * Sets the borderBottom 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 setBorderTop(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderTop(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 left border for a region of cells by manipulating the cell style * of the individual cells on the left * * @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 setBorderLeft(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderLeft(border, region, sheet, workbook); }
/** * Sets the rightBorderColor attribute of the HSSFRegionUtil object * * @param color The color of the 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 setRightBorderColor(int color, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setRightBorderColor(color, region, sheet); }
/** * Sets the topBorderColor attribute of the HSSFRegionUtil object * * @param color The color of the 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 setTopBorderColor(int color, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setTopBorderColor(color, 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); }
/** * Sets the borderBottom 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 setBorderBottom(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderBottom(border, region, sheet, workbook); }
/** * Sets the borderBottom 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 setBorderTop(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderTop(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 left border for a region of cells by manipulating the cell style * of the individual cells on the left * * @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 setBorderLeft(int border, CellRangeAddress region, HSSFSheet sheet, HSSFWorkbook workbook) { RegionUtil.setBorderLeft(border, region, sheet, workbook); }