import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
/**
* <p>
/**
* Provides various extents of the properties being added to the template
+ * Note that the Border Extent differs from a BorderStyle. A BorderStyle
+ * refers to the border around a single cell while a BorderExtent refers to
+ * borders around and through an area of cells.
*/
public enum Extent {
/**
int row = range.getFirstRow();
int firstCol = range.getFirstColumn();
int lastCol = range.getLastColumn();
- boolean addBottom = borderType == BorderStyle.NONE && row > 0;
+ boolean addBottom = (borderType == BorderStyle.NONE && row > 0);
for (int i = firstCol; i <= lastCol; i++) {
addProperty(row, i, CellUtil.BORDER_TOP, borderType);
if (addBottom) {
int row = range.getLastRow();
int firstCol = range.getFirstColumn();
int lastCol = range.getLastColumn();
- boolean addTop = (borderType == BorderStyle.NONE
- && row < _ss.getLastRowIndex());
+ boolean addTop = (borderType == BorderStyle.NONE && row < _ss.getLastRowIndex());
for (int i = firstCol; i <= lastCol; i++) {
addProperty(row, i, CellUtil.BORDER_BOTTOM, borderType);
if (addTop) {
int firstRow = range.getFirstRow();
int lastRow = range.getLastRow();
int col = range.getFirstColumn();
- boolean addRight = borderType == BorderStyle.NONE && col > 0;
+ boolean addRight = (borderType == BorderStyle.NONE && col > 0);
for (int i = firstRow; i <= lastRow; i++) {
addProperty(i, col, CellUtil.BORDER_LEFT, borderType);
if (addRight) {
int firstRow = range.getFirstRow();
int lastRow = range.getLastRow();
int col = range.getLastColumn();
- boolean addLeft = (borderType == BorderStyle.NONE
- && col < _ss.getLastColumnIndex());
+ boolean addLeft = (borderType == BorderStyle.NONE && col < _ss.getLastColumnIndex());
for (int i = firstRow; i <= lastRow; i++) {
addProperty(i, col, CellUtil.BORDER_RIGHT, borderType);
if (addLeft) {
* the ones that have been drawn by the {@link #drawBorders} and
* {@link #drawBorderColors} methods.
*
- * @param sheet
- * - {@link Sheet} on which to apply borders
+ * @param sheet Sheet on which to apply borders
*/
public void applyBorders(Sheet sheet) {
- Workbook wb = sheet.getWorkbook();
- SpreadsheetVersion ss = wb.getSpreadsheetVersion();
+ SpreadsheetVersion ss = sheet.getWorkbook().getSpreadsheetVersion();
int lastValidRow = ss.getLastRowIndex();
int lastValidCol = ss.getLastColumnIndex();
for (Entry<CellAddress, Map<String, Object>> entry : _propertyTemplate.entrySet()) {
/**
* Sets the color for a group of cell borders for a cell range. The borders
* are not applied to the cells at this time, just the template is drawn. If
- * the borders do not exist, a BORDER_THIN border is used. To apply the
+ * the borders do not exist, a {@link BorderStyle#THIN} border is used. To apply the
* drawn borders to a sheet, use {@link #applyBorders}.
*
- * @param range
- * - range of cells on which colors are
- * set.
- * @param color
- * - Color index from {@link IndexedColors} used to draw the
- * borders.
- * @param extent
- * - of the borders for which
- * colors are set.
+ * @param range range of cells on which colors are set.
+ * @param color Color index from {@link IndexedColors} used to draw the borders.
+ * @param extent Extent of the borders for which colors are set.
*/
public void drawBorderColors(CellRangeAddress range, short color, Extent extent) {
switch (extent) {
* Sets the color of the top border for a range of cells.
* </p>
*
- * @param range
- * - range of cells on which colors are
- * set.
- * @param color
- * - Color index from {@link IndexedColors} used to draw the
- * borders.
+ * @param range 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();
* Sets the color of the bottom border for a range of cells.
* </p>
*
- * @param range
- * - range of cells on which colors are
- * set.
- * @param color
- * - Color index from {@link IndexedColors} used to draw the
- * borders.
+ * @param range 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();
* Sets the color of the left border for a range of cells.
* </p>
*
- * @param range
- * - range of cells on which colors are
- * set.
- * @param color
- * - Color index from {@link IndexedColors} used to draw the
- * borders.
+ * @param range 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();
/**
* <p>
* Sets the color of the right border for a range of cells. If the border is
- * not drawn, it defaults to BORDER_THIN
+ * not drawn, it defaults to {@link BorderStyle#THIN}
* </p>
*
- * @param range
- * - range of cells on which colors are
- * set.
- * @param color
- * - Color index from {@link IndexedColors} used to draw the
- * borders.
+ * @param range 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();
* Sets the color of the outside borders for a range of cells.
* </p>
*
- * @param range
- * - range of cells on which colors are
- * set.
- * @param color
- * - Color index from {@link IndexedColors} used to draw the
- * borders.
- * @param extent
- * - of the borders for which
- * colors are set. Valid Values are:
+ * @param range range of cells on which colors are set.
+ * @param color Color index from {@link IndexedColors} used to draw the borders.
+ * @param extent Extent of the borders for which colors are set. Valid Values are:
* <ul>
* <li>Extent.ALL</li>
* <li>Extent.HORIZONTAL</li>
* Sets the color of the horizontal borders for a range of cells.
* </p>
*
- * @param range
- * - range of cells on which colors are
- * set.
- * @param color
- * - Color index from {@link IndexedColors} used to draw the
- * borders.
- * @param extent
- * - of the borders for which
- * colors are set. Valid Values are:
+ * @param range range of cells on which colors are set.
+ * @param color Color index from {@link IndexedColors} used to draw the borders.
+ * @param extent Extent of the borders for which colors are set. Valid Values are:
* <ul>
* <li>Extent.ALL</li>
* <li>Extent.INSIDE</li>
* Sets the color of the vertical borders for a range of cells.
* </p>
*
- * @param range
- * - range of cells on which colors are
- * set.
- * @param color
- * - Color index from {@link IndexedColors} used to draw the
- * borders.
- * @param extent
- * - Extent of the borders for which
- * colors are set. Valid Values are:
+ * @param range range of cells on which colors are set.
+ * @param color Color index from {@link IndexedColors} used to draw the borders.
+ * @param extent Extent of the borders for which colors are set. Valid Values are:
* <ul>
* <li>Extent.ALL</li>
* <li>Extent.INSIDE</li>
* Removes all border properties from this PropertyTemplate for the
* specified range.
*
- * @parm range - range of cells to remove borders.
+ * @param range - range of cells to remove borders.
*/
private void removeBorderColors(CellRangeAddress range) {
int firstRow = range.getFirstRow();