/** * Sets the right border color for a region of cells by manipulating the cell style of the individual * cells on the right * * @param color The color of the border * @param region The region that should have the border * @param sheet The sheet that the region is on. * @since POI 3.15 beta 2 */ public static void setRightBorderColor(int color, CellRangeAddress region, Sheet sheet) { int rowStart = region.getFirstRow(); int rowEnd = region.getLastRow(); int column = region.getLastColumn(); CellPropertySetter cps = new CellPropertySetter(CellUtil.RIGHT_BORDER_COLOR, color); for (int i = rowStart; i <= rowEnd; i++) { cps.setProperty(CellUtil.getRow(i, sheet), column); } }
/** * Sets the top border style for a region of cells by manipulating the cell style of the individual * cells on the top * * @param border The new border * @param region The region that should have the border * @param sheet The sheet that the region is on. * @since POI 3.16 beta 1 */ public static void setBorderTop(BorderStyle border, CellRangeAddress region, Sheet sheet) { int colStart = region.getFirstColumn(); int colEnd = region.getLastColumn(); int rowIndex = region.getFirstRow(); CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_TOP, border); Row row = CellUtil.getRow(rowIndex, sheet); for (int i = colStart; i <= colEnd; i++) { cps.setProperty(row, i); } }
/** * Sets the bottom border color for a region of cells by manipulating the cell style of the individual * cells on the bottom * * @param color The color of the border * @param region The region that should have the border * @param sheet The sheet that the region is on. * @since POI 3.15 beta 2 */ public static void setBottomBorderColor(int color, CellRangeAddress region, Sheet sheet) { int colStart = region.getFirstColumn(); int colEnd = region.getLastColumn(); int rowIndex = region.getLastRow(); CellPropertySetter cps = new CellPropertySetter(CellUtil.BOTTOM_BORDER_COLOR, color); Row row = CellUtil.getRow(rowIndex, sheet); for (int i = colStart; i <= colEnd; i++) { cps.setProperty(row, i); } }
/** * Sets the left border style 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 sheet The sheet that the region is on. * @since POI 3.16 beta 1 */ public static void setBorderLeft(BorderStyle border, CellRangeAddress region, Sheet sheet) { int rowStart = region.getFirstRow(); int rowEnd = region.getLastRow(); int column = region.getFirstColumn(); CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_LEFT, border); for (int i = rowStart; i <= rowEnd; i++) { cps.setProperty(CellUtil.getRow(i, sheet), column); } }
/** * Sets the left border color for a region of cells by manipulating the cell style of the individual * cells on the left * * @param color The color of the border * @param region The region that should have the border * @param sheet The sheet that the region is on. * @since POI 3.15 beta 2 */ public static void setLeftBorderColor(int color, CellRangeAddress region, Sheet sheet) { int rowStart = region.getFirstRow(); int rowEnd = region.getLastRow(); int column = region.getFirstColumn(); CellPropertySetter cps = new CellPropertySetter(CellUtil.LEFT_BORDER_COLOR, color); for (int i = rowStart; i <= rowEnd; i++) { cps.setProperty(CellUtil.getRow(i, sheet), column); } }
/** * Sets the right border style for a region of cells by manipulating the cell style of the individual * cells on the right * * @param border The new border * @param region The region that should have the border * @param sheet The sheet that the region is on. * @since POI 3.16 beta 1 */ public static void setBorderRight(BorderStyle border, CellRangeAddress region, Sheet sheet) { int rowStart = region.getFirstRow(); int rowEnd = region.getLastRow(); int column = region.getLastColumn(); CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_RIGHT, border); for (int i = rowStart; i <= rowEnd; i++) { cps.setProperty(CellUtil.getRow(i, sheet), column); } }
/** * Sets the top border color for a region of cells by manipulating the cell style of the individual * cells on the top * * @param color The color of the border * @param region The region that should have the border * @param sheet The sheet that the region is on. * @since POI 3.15 beta 2 */ public static void setTopBorderColor(int color, CellRangeAddress region, Sheet sheet) { int colStart = region.getFirstColumn(); int colEnd = region.getLastColumn(); int rowIndex = region.getFirstRow(); CellPropertySetter cps = new CellPropertySetter(CellUtil.TOP_BORDER_COLOR, color); Row row = CellUtil.getRow(rowIndex, sheet); for (int i = colStart; i <= colEnd; i++) { cps.setProperty(row, i); } } }
/** * Sets the bottom border style for a region of cells by manipulating the cell style of the individual * cells on the bottom * * @param border The new border * @param region The region that should have the border * @param sheet The sheet that the region is on. * @since POI 3.16 beta 1 */ public static void setBorderBottom(BorderStyle border, CellRangeAddress region, Sheet sheet) { int colStart = region.getFirstColumn(); int colEnd = region.getLastColumn(); int rowIndex = region.getLastRow(); CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_BOTTOM, border); Row row = CellUtil.getRow(rowIndex, sheet); for (int i = colStart; i <= colEnd; i++) { cps.setProperty(row, i); } }
/** * Applies the drawn borders to a Sheet. The borders that are applied are * the ones that have been drawn by the {@link #drawBorders} and * {@link #drawBorderColors} methods. * * @param sheet * - {@link Sheet} on which to apply borders */ public void applyBorders(Sheet sheet) { Workbook wb = sheet.getWorkbook(); for (Map.Entry<CellAddress, Map<String, Object>> entry : _propertyTemplate .entrySet()) { CellAddress cellAddress = entry.getKey(); if (cellAddress.getRow() < wb.getSpreadsheetVersion().getMaxRows() && cellAddress.getColumn() < wb.getSpreadsheetVersion() .getMaxColumns()) { Map<String, Object> properties = entry.getValue(); Row row = CellUtil.getRow(cellAddress.getRow(), sheet); Cell cell = CellUtil.getCell(row, cellAddress.getColumn()); CellUtil.setCellStyleProperties(cell, properties); } } }
/** * Get a row from the spreadsheet, and create it if it doesn't exist. * *@param rowIndex The 0 based row number *@param sheet The sheet that the row is part of. *@return The row indicated by the rowCounter */ public static HSSFRow getRow(int rowIndex, HSSFSheet sheet) { return (HSSFRow) CellUtil.getRow(rowIndex, sheet); }
/** * Get a row from the spreadsheet, and create it if it doesn't exist. * *@param rowIndex The 0 based row number *@param sheet The sheet that the row is part of. *@return The row indicated by the rowCounter */ public static HSSFRow getRow(int rowIndex, HSSFSheet sheet) { return (HSSFRow) CellUtil.getRow(rowIndex, sheet); }
/** * Sets the left border style 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 sheet The sheet that the region is on. * @since POI 3.16 beta 1 */ public static void setBorderLeft(BorderStyle border, CellRangeAddress region, Sheet sheet) { int rowStart = region.getFirstRow(); int rowEnd = region.getLastRow(); int column = region.getFirstColumn(); CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_LEFT, border); for (int i = rowStart; i <= rowEnd; i++) { cps.setProperty(CellUtil.getRow(i, sheet), column); } }
/** * Sets the right border color for a region of cells by manipulating the cell style of the individual * cells on the right * * @param color The color of the border * @param region The region that should have the border * @param sheet The sheet that the region is on. * @since POI 3.15 beta 2 */ public static void setRightBorderColor(int color, CellRangeAddress region, Sheet sheet) { int rowStart = region.getFirstRow(); int rowEnd = region.getLastRow(); int column = region.getLastColumn(); CellPropertySetter cps = new CellPropertySetter(CellUtil.RIGHT_BORDER_COLOR, color); for (int i = rowStart; i <= rowEnd; i++) { cps.setProperty(CellUtil.getRow(i, sheet), column); } }
/** * Sets the left border color for a region of cells by manipulating the cell style of the individual * cells on the left * * @param color The color of the border * @param region The region that should have the border * @param sheet The sheet that the region is on. * @since POI 3.15 beta 2 */ public static void setLeftBorderColor(int color, CellRangeAddress region, Sheet sheet) { int rowStart = region.getFirstRow(); int rowEnd = region.getLastRow(); int column = region.getFirstColumn(); CellPropertySetter cps = new CellPropertySetter(CellUtil.LEFT_BORDER_COLOR, color); for (int i = rowStart; i <= rowEnd; i++) { cps.setProperty(CellUtil.getRow(i, sheet), column); } }
/** * Sets the right border style for a region of cells by manipulating the cell style of the individual * cells on the right * * @param border The new border * @param region The region that should have the border * @param sheet The sheet that the region is on. * @since POI 3.16 beta 1 */ public static void setBorderRight(BorderStyle border, CellRangeAddress region, Sheet sheet) { int rowStart = region.getFirstRow(); int rowEnd = region.getLastRow(); int column = region.getLastColumn(); CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_RIGHT, border); for (int i = rowStart; i <= rowEnd; i++) { cps.setProperty(CellUtil.getRow(i, sheet), column); } }
/** * Sets the borderBottom attribute of the RegionUtil 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, Sheet sheet, Workbook workbook) { int colStart = region.getFirstColumn(); int colEnd = region.getLastColumn(); int rowIndex = region.getLastRow(); CellPropertySetter cps = new CellPropertySetter(workbook, CellUtil.BORDER_BOTTOM, border); Row row = CellUtil.getRow(rowIndex, sheet); for (int i = colStart; i <= colEnd; i++) { cps.setProperty(row, i); } }
/** * Sets the top border style for a region of cells by manipulating the cell style of the individual * cells on the top * * @param border The new border * @param region The region that should have the border * @param sheet The sheet that the region is on. * @since POI 3.16 beta 1 */ public static void setBorderTop(BorderStyle border, CellRangeAddress region, Sheet sheet) { int colStart = region.getFirstColumn(); int colEnd = region.getLastColumn(); int rowIndex = region.getFirstRow(); CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_TOP, border); Row row = CellUtil.getRow(rowIndex, sheet); for (int i = colStart; i <= colEnd; i++) { cps.setProperty(row, i); } }
/** * Sets the leftBorderColor attribute of the RegionUtil 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, Sheet sheet, Workbook workbook) { int rowStart = region.getFirstRow(); int rowEnd = region.getLastRow(); int column = region.getFirstColumn(); CellPropertySetter cps = new CellPropertySetter(workbook, CellUtil.LEFT_BORDER_COLOR, color); for (int i = rowStart; i <= rowEnd; i++) { cps.setProperty(CellUtil.getRow(i, sheet), column); } }
/** * Sets the borderBottom attribute of the RegionUtil 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, Sheet sheet, Workbook workbook) { int colStart = region.getFirstColumn(); int colEnd = region.getLastColumn(); int rowIndex = region.getFirstRow(); CellPropertySetter cps = new CellPropertySetter(workbook, CellUtil.BORDER_TOP, border); Row row = CellUtil.getRow(rowIndex, sheet); for (int i = colStart; i <= colEnd; i++) { cps.setProperty(row, i); } }
/** * Sets the bottom border color for a region of cells by manipulating the cell style of the individual * cells on the bottom * * @param color The color of the border * @param region The region that should have the border * @param sheet The sheet that the region is on. * @since POI 3.15 beta 2 */ public static void setBottomBorderColor(int color, CellRangeAddress region, Sheet sheet) { int colStart = region.getFirstColumn(); int colEnd = region.getLastColumn(); int rowIndex = region.getLastRow(); CellPropertySetter cps = new CellPropertySetter(CellUtil.BOTTOM_BORDER_COLOR, color); Row row = CellUtil.getRow(rowIndex, sheet); for (int i = colStart; i <= colEnd; i++) { cps.setProperty(row, i); } }