/** * Adds a property to this {@link PropertyTemplate} for a given cell * * @param row * @param col * @param property * @param value */ private void addProperty(int row, int col, String property, short value) { addProperty(row, col, property, Short.valueOf(value)); }
/** * <p> * Draws the left border for a range of cells * </p> * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. */ private void drawLeftBorder(CellRangeAddress range, BorderStyle borderType) { int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); int col = range.getFirstColumn(); for (int i = firstRow; i <= lastRow; i++) { addProperty(i, col, CellUtil.BORDER_LEFT, borderType); if (borderType == BorderStyle.NONE && col > 0) { addProperty(i, col - 1, CellUtil.BORDER_RIGHT, borderType); } } }
/** * <p> * Draws the top border for a range of cells * </p> * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. */ private void drawTopBorder(CellRangeAddress range, BorderStyle borderType) { int row = range.getFirstRow(); int firstCol = range.getFirstColumn(); int lastCol = range.getLastColumn(); for (int i = firstCol; i <= lastCol; i++) { addProperty(row, i, CellUtil.BORDER_TOP, borderType); if (borderType == BorderStyle.NONE && row > 0) { addProperty(row - 1, i, CellUtil.BORDER_BOTTOM, borderType); } } }
/** * <p> * Draws the right border for a range of cells * </p> * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. */ private void drawRightBorder(CellRangeAddress range, BorderStyle borderType) { int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); int col = range.getLastColumn(); for (int i = firstRow; i <= lastRow; i++) { addProperty(i, col, CellUtil.BORDER_RIGHT, borderType); if (borderType == BorderStyle.NONE && col < SpreadsheetVersion.EXCEL2007.getMaxColumns() - 1) { addProperty(i, col + 1, CellUtil.BORDER_LEFT, borderType); } } }
/** * <p> * Draws the bottom border for a range of cells * </p> * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. */ private void drawBottomBorder(CellRangeAddress range, BorderStyle borderType) { int row = range.getLastRow(); int firstCol = range.getFirstColumn(); int lastCol = range.getLastColumn(); for (int i = firstCol; i <= lastCol; i++) { addProperty(row, i, CellUtil.BORDER_BOTTOM, borderType); if (borderType == BorderStyle.NONE && row < SpreadsheetVersion.EXCEL2007.getMaxRows() - 1) { addProperty(row + 1, i, CellUtil.BORDER_TOP, borderType); } } }
/** * <p> * Sets the color of the top border for a range of cells. * </p> * * @param range * - {@link CellRangeAddress} range of cells on which colors are * set. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. */ private void drawTopBorderColor(CellRangeAddress range, short color) { int row = range.getFirstRow(); int firstCol = range.getFirstColumn(); int lastCol = range.getLastColumn(); for (int i = firstCol; i <= lastCol; i++) { if (getBorderStyle(row, i, CellUtil.BORDER_TOP) == BorderStyle.NONE) { drawTopBorder(new CellRangeAddress(row, row, i, i), BorderStyle.THIN); } addProperty(row, i, CellUtil.TOP_BORDER_COLOR, color); } }
/** * <p> * Sets the color of the right border for a range of cells. If the border is * not drawn, it defaults to BORDER_THIN * </p> * * @param range * - {@link CellRangeAddress} range of cells on which colors are * set. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. */ private void drawRightBorderColor(CellRangeAddress range, short color) { int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); int col = range.getLastColumn(); for (int i = firstRow; i <= lastRow; i++) { if (getBorderStyle(i, col, CellUtil.BORDER_RIGHT) == BorderStyle.NONE) { drawRightBorder(new CellRangeAddress(i, i, col, col), BorderStyle.THIN); } addProperty(i, col, CellUtil.RIGHT_BORDER_COLOR, color); } }
/** * <p> * Sets the color of the bottom border for a range of cells. * </p> * * @param range * - {@link CellRangeAddress} range of cells on which colors are * set. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. */ private void drawBottomBorderColor(CellRangeAddress range, short color) { int row = range.getLastRow(); int firstCol = range.getFirstColumn(); int lastCol = range.getLastColumn(); for (int i = firstCol; i <= lastCol; i++) { if (getBorderStyle(row, i, CellUtil.BORDER_BOTTOM) == BorderStyle.NONE) { drawBottomBorder(new CellRangeAddress(row, row, i, i), BorderStyle.THIN); } addProperty(row, i, CellUtil.BOTTOM_BORDER_COLOR, color); } }
/** * <p> * Sets the color of the left border for a range of cells. * </p> * * @param range * - {@link CellRangeAddress} range of cells on which colors are * set. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. */ private void drawLeftBorderColor(CellRangeAddress range, short color) { int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); int col = range.getFirstColumn(); for (int i = firstRow; i <= lastRow; i++) { if (getBorderStyle(i, col, CellUtil.BORDER_LEFT) == BorderStyle.NONE) { drawLeftBorder(new CellRangeAddress(i, i, col, col), BorderStyle.THIN); } addProperty(i, col, CellUtil.LEFT_BORDER_COLOR, color); } }
/** * Adds a property to this {@link PropertyTemplate} for a given cell * * @param row * @param col * @param property * @param value */ private void addProperty(int row, int col, String property, short value) { addProperty(row, col, property, Short.valueOf(value)); }
/** * <p> * Draws the top border for a range of cells * </p> * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. */ private void drawTopBorder(CellRangeAddress range, BorderStyle borderType) { int row = range.getFirstRow(); int firstCol = range.getFirstColumn(); int lastCol = range.getLastColumn(); for (int i = firstCol; i <= lastCol; i++) { addProperty(row, i, CellUtil.BORDER_TOP, borderType); if (borderType == BorderStyle.NONE && row > 0) { addProperty(row - 1, i, CellUtil.BORDER_BOTTOM, borderType); } } }
/** * <p> * Draws the left border for a range of cells * </p> * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. */ private void drawLeftBorder(CellRangeAddress range, BorderStyle borderType) { int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); int col = range.getFirstColumn(); for (int i = firstRow; i <= lastRow; i++) { addProperty(i, col, CellUtil.BORDER_LEFT, borderType); if (borderType == BorderStyle.NONE && col > 0) { addProperty(i, col - 1, CellUtil.BORDER_RIGHT, borderType); } } }
/** * <p> * Draws the right border for a range of cells * </p> * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. */ private void drawRightBorder(CellRangeAddress range, BorderStyle borderType) { int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); int col = range.getLastColumn(); for (int i = firstRow; i <= lastRow; i++) { addProperty(i, col, CellUtil.BORDER_RIGHT, borderType); if (borderType == BorderStyle.NONE && col < SpreadsheetVersion.EXCEL2007.getMaxColumns() - 1) { addProperty(i, col + 1, CellUtil.BORDER_LEFT, borderType); } } }
/** * <p> * Draws the bottom border for a range of cells * </p> * * @param range * - {@link CellRangeAddress} range of cells on which borders are * drawn. * @param borderType * - Type of border to draw. {@link BorderStyle}. */ private void drawBottomBorder(CellRangeAddress range, BorderStyle borderType) { int row = range.getLastRow(); int firstCol = range.getFirstColumn(); int lastCol = range.getLastColumn(); for (int i = firstCol; i <= lastCol; i++) { addProperty(row, i, CellUtil.BORDER_BOTTOM, borderType); if (borderType == BorderStyle.NONE && row < SpreadsheetVersion.EXCEL2007.getMaxRows() - 1) { addProperty(row + 1, i, CellUtil.BORDER_TOP, borderType); } } }
/** * <p> * Sets the color of the top border for a range of cells. * </p> * * @param range * - {@link CellRangeAddress} range of cells on which colors are * set. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. */ private void drawTopBorderColor(CellRangeAddress range, short color) { int row = range.getFirstRow(); int firstCol = range.getFirstColumn(); int lastCol = range.getLastColumn(); for (int i = firstCol; i <= lastCol; i++) { if (getBorderStyle(row, i, CellUtil.BORDER_TOP) == BorderStyle.NONE) { drawTopBorder(new CellRangeAddress(row, row, i, i), BorderStyle.THIN); } addProperty(row, i, CellUtil.TOP_BORDER_COLOR, color); } }
/** * <p> * Sets the color of the right border for a range of cells. If the border is * not drawn, it defaults to BORDER_THIN * </p> * * @param range * - {@link CellRangeAddress} range of cells on which colors are * set. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. */ private void drawRightBorderColor(CellRangeAddress range, short color) { int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); int col = range.getLastColumn(); for (int i = firstRow; i <= lastRow; i++) { if (getBorderStyle(i, col, CellUtil.BORDER_RIGHT) == BorderStyle.NONE) { drawRightBorder(new CellRangeAddress(i, i, col, col), BorderStyle.THIN); } addProperty(i, col, CellUtil.RIGHT_BORDER_COLOR, color); } }
/** * <p> * Sets the color of the bottom border for a range of cells. * </p> * * @param range * - {@link CellRangeAddress} range of cells on which colors are * set. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. */ private void drawBottomBorderColor(CellRangeAddress range, short color) { int row = range.getLastRow(); int firstCol = range.getFirstColumn(); int lastCol = range.getLastColumn(); for (int i = firstCol; i <= lastCol; i++) { if (getBorderStyle(row, i, CellUtil.BORDER_BOTTOM) == BorderStyle.NONE) { drawBottomBorder(new CellRangeAddress(row, row, i, i), BorderStyle.THIN); } addProperty(row, i, CellUtil.BOTTOM_BORDER_COLOR, color); } }
/** * <p> * Sets the color of the left border for a range of cells. * </p> * * @param range * - {@link CellRangeAddress} range of cells on which colors are * set. * @param color * - Color index from {@link IndexedColors} used to draw the * borders. */ private void drawLeftBorderColor(CellRangeAddress range, short color) { int firstRow = range.getFirstRow(); int lastRow = range.getLastRow(); int col = range.getFirstColumn(); for (int i = firstRow; i <= lastRow; i++) { if (getBorderStyle(i, col, CellUtil.BORDER_LEFT) == BorderStyle.NONE) { drawLeftBorder(new CellRangeAddress(i, i, col, col), BorderStyle.THIN); } addProperty(i, col, CellUtil.LEFT_BORDER_COLOR, color); } }