bug 60187: replace methods operating on BorderStyle codes with BorderStyle enums

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1762856 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-09-30 06:39:29 +00:00
parent 6ccf74712f
commit da304a486e
2 changed files with 172 additions and 22 deletions

View File

@ -17,10 +17,12 @@
package org.apache.poi.ss.util; package org.apache.poi.ss.util;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.util.Removal;
/** /**
* Various utility functions that make working with a region of cells easier. * Various utility functions that make working with a region of cells easier.
@ -47,32 +49,37 @@ public final class RegionUtil {
public void setProperty(Row row, int column) { public void setProperty(Row row, int column) {
// create cell if it does not exist
Cell cell = CellUtil.getCell(row, column); Cell cell = CellUtil.getCell(row, column);
CellUtil.setCellStyleProperty(cell, _propertyName, _propertyValue); CellUtil.setCellStyleProperty(cell, _propertyName, _propertyValue);
} }
} }
/** /**
* Sets the left border for a region of cells by manipulating the cell style of the individual * Sets the left border style for a region of cells by manipulating the cell style of the individual
* cells on the left * cells on the left
* *
* @param border The new border * @param border The new border
* @param region The region that should have the border * @param region The region that should have the border
* @param workbook The workbook that the region is on. * @param workbook The workbook that the region is on.
* @param sheet The sheet that the region is on. * @param sheet The sheet that the region is on.
* @deprecated 3.15 beta 2. Use {@link #setBorderLeft(int, CellRangeAddress, Sheet)}. * @deprecated 3.15 beta 2. Use {@link #setBorderLeft(BorderStyle, CellRangeAddress, Sheet)}.
*/ */
@Removal(version="3.17")
public static void setBorderLeft(int border, CellRangeAddress region, Sheet sheet, Workbook workbook) { public static void setBorderLeft(int border, CellRangeAddress region, Sheet sheet, Workbook workbook) {
setBorderLeft(border, region, sheet); setBorderLeft(border, region, sheet);
} }
/** /**
* Sets the left border for a region of cells by manipulating the cell style of the individual * Sets the left border style for a region of cells by manipulating the cell style of the individual
* cells on the left * cells on the left
* *
* @param border The new border * @param border The new border
* @param region The region that should have the border * @param region The region that should have the border
* @param sheet The sheet that the region is on. * @param sheet The sheet that the region is on.
* @since POI 3.15 beta 2
* @deprecated 3.16 beta 1. Use {@link #setBorderLeft(BorderStyle, CellRangeAddress, Sheet)}.
*/ */
@Removal(version="3.18")
public static void setBorderLeft(int border, CellRangeAddress region, Sheet sheet) { public static void setBorderLeft(int border, CellRangeAddress region, Sheet sheet) {
int rowStart = region.getFirstRow(); int rowStart = region.getFirstRow();
int rowEnd = region.getLastRow(); int rowEnd = region.getLastRow();
@ -83,6 +90,18 @@ public final class RegionUtil {
cps.setProperty(CellUtil.getRow(i, sheet), column); cps.setProperty(CellUtil.getRow(i, sheet), column);
} }
} }
/**
* 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) {
setBorderLeft(border.getCode(), region, sheet);
}
/** /**
* Sets the left border color for a region of cells by manipulating the cell style of the individual * Sets the left border color for a region of cells by manipulating the cell style of the individual
@ -94,6 +113,7 @@ public final class RegionUtil {
* @param sheet The sheet that the region is on. * @param sheet The sheet that the region is on.
* @deprecated 3.15 beta 2. Use {@link #setLeftBorderColor(int, CellRangeAddress, Sheet)}. * @deprecated 3.15 beta 2. Use {@link #setLeftBorderColor(int, CellRangeAddress, Sheet)}.
*/ */
@Removal(version="3.17")
public static void setLeftBorderColor(int color, CellRangeAddress region, Sheet sheet, Workbook workbook) { public static void setLeftBorderColor(int color, CellRangeAddress region, Sheet sheet, Workbook workbook) {
setLeftBorderColor(color, region, sheet); setLeftBorderColor(color, region, sheet);
} }
@ -104,6 +124,7 @@ public final class RegionUtil {
* @param color The color of the border * @param color The color of the border
* @param region The region that should have the border * @param region The region that should have the border
* @param sheet The sheet that the region is on. * @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) { public static void setLeftBorderColor(int color, CellRangeAddress region, Sheet sheet) {
int rowStart = region.getFirstRow(); int rowStart = region.getFirstRow();
@ -117,26 +138,30 @@ public final class RegionUtil {
} }
/** /**
* Sets the right border for a region of cells by manipulating the cell style of the individual * Sets the right border style for a region of cells by manipulating the cell style of the individual
* cells on the right * cells on the right
* *
* @param border The new border * @param border The new border
* @param region The region that should have the border * @param region The region that should have the border
* @param workbook The workbook that the region is on. * @param workbook The workbook that the region is on.
* @param sheet The sheet that the region is on. * @param sheet The sheet that the region is on.
* @deprecated 3.15 beta 2. Use {@link #setBorderRight(int, CellRangeAddress, Sheet)}. * @deprecated 3.15 beta 2. Use {@link #setBorderRight(BorderStyle, CellRangeAddress, Sheet)}.
*/ */
@Removal(version="3.17")
public static void setBorderRight(int border, CellRangeAddress region, Sheet sheet, Workbook workbook) { public static void setBorderRight(int border, CellRangeAddress region, Sheet sheet, Workbook workbook) {
setBorderRight(border, region, sheet); setBorderRight(border, region, sheet);
} }
/** /**
* Sets the right border for a region of cells by manipulating the cell style of the individual * Sets the right border style for a region of cells by manipulating the cell style of the individual
* cells on the right * cells on the right
* *
* @param border The new border * @param border The new border
* @param region The region that should have the border * @param region The region that should have the border
* @param sheet The sheet that the region is on. * @param sheet The sheet that the region is on.
* @since POI 3.15 beta 2
* @deprecated POI 3.16 beta 1. Use {@link #setBorderRight(BorderStyle, CellRangeAddress, Sheet)}.
*/ */
@Removal(version="3.18")
public static void setBorderRight(int border, CellRangeAddress region, Sheet sheet) { public static void setBorderRight(int border, CellRangeAddress region, Sheet sheet) {
int rowStart = region.getFirstRow(); int rowStart = region.getFirstRow();
int rowEnd = region.getLastRow(); int rowEnd = region.getLastRow();
@ -147,6 +172,18 @@ public final class RegionUtil {
cps.setProperty(CellUtil.getRow(i, sheet), column); 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) {
setBorderRight(border.getCode(), region, sheet);
}
/** /**
* Sets the right border color for a region of cells by manipulating the cell style of the individual * Sets the right border color for a region of cells by manipulating the cell style of the individual
@ -158,6 +195,7 @@ public final class RegionUtil {
* @param sheet The sheet that the region is on. * @param sheet The sheet that the region is on.
* @deprecated 3.15 beta 2. Use {@link #setRightBorderColor(int, CellRangeAddress, Sheet)}. * @deprecated 3.15 beta 2. Use {@link #setRightBorderColor(int, CellRangeAddress, Sheet)}.
*/ */
@Removal(version="3.17")
public static void setRightBorderColor(int color, CellRangeAddress region, Sheet sheet, Workbook workbook) { public static void setRightBorderColor(int color, CellRangeAddress region, Sheet sheet, Workbook workbook) {
setRightBorderColor(color, region, sheet); setRightBorderColor(color, region, sheet);
} }
@ -168,6 +206,7 @@ public final class RegionUtil {
* @param color The color of the border * @param color The color of the border
* @param region The region that should have the border * @param region The region that should have the border
* @param sheet The sheet that the region is on. * @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) { public static void setRightBorderColor(int color, CellRangeAddress region, Sheet sheet) {
int rowStart = region.getFirstRow(); int rowStart = region.getFirstRow();
@ -181,26 +220,30 @@ public final class RegionUtil {
} }
/** /**
* Sets the bottom border for a region of cells by manipulating the cell style of the individual * Sets the bottom border style for a region of cells by manipulating the cell style of the individual
* cells on the bottom * cells on the bottom
* *
* @param border The new border * @param border The new border
* @param region The region that should have the border * @param region The region that should have the border
* @param workbook The workbook that the region is on. * @param workbook The workbook that the region is on.
* @param sheet The sheet that the region is on. * @param sheet The sheet that the region is on.
* @deprecated 3.15 beta 2. Use {@link #setBorderBottom(int, CellRangeAddress, Sheet)}. * @deprecated 3.15 beta 2. Use {@link #setBorderBottom(BorderStyle, CellRangeAddress, Sheet)}.
*/ */
@Removal(version="3.17")
public static void setBorderBottom(int border, CellRangeAddress region, Sheet sheet, Workbook workbook) { public static void setBorderBottom(int border, CellRangeAddress region, Sheet sheet, Workbook workbook) {
setBorderBottom(border, region, sheet); setBorderBottom(border, region, sheet);
} }
/** /**
* Sets the bottom border for a region of cells by manipulating the cell style of the individual * Sets the bottom border style for a region of cells by manipulating the cell style of the individual
* cells on the bottom * cells on the bottom
* *
* @param border The new border * @param border The new border
* @param region The region that should have the border * @param region The region that should have the border
* @param sheet The sheet that the region is on. * @param sheet The sheet that the region is on.
* @since POI 3.15 beta 2
* @deprecated POI 3.16 beta 1. Use {@link #setBorderBottom(BorderStyle, CellRangeAddress, Sheet)}.
*/ */
@Removal(version="3.18")
public static void setBorderBottom(int border, CellRangeAddress region, Sheet sheet) { public static void setBorderBottom(int border, CellRangeAddress region, Sheet sheet) {
int colStart = region.getFirstColumn(); int colStart = region.getFirstColumn();
int colEnd = region.getLastColumn(); int colEnd = region.getLastColumn();
@ -211,6 +254,18 @@ public final class RegionUtil {
cps.setProperty(row, 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) {
setBorderBottom(border.getCode(), region, sheet);
}
/** /**
* Sets the bottom border color for a region of cells by manipulating the cell style of the individual * Sets the bottom border color for a region of cells by manipulating the cell style of the individual
@ -222,6 +277,7 @@ public final class RegionUtil {
* @param sheet The sheet that the region is on. * @param sheet The sheet that the region is on.
* @deprecated 3.15 beta 2. Use {@link #setBottomBorderColor(int, CellRangeAddress, Sheet)}. * @deprecated 3.15 beta 2. Use {@link #setBottomBorderColor(int, CellRangeAddress, Sheet)}.
*/ */
@Removal(version="3.17")
public static void setBottomBorderColor(int color, CellRangeAddress region, Sheet sheet, Workbook workbook) { public static void setBottomBorderColor(int color, CellRangeAddress region, Sheet sheet, Workbook workbook) {
setBottomBorderColor(color, region, sheet); setBottomBorderColor(color, region, sheet);
} }
@ -232,6 +288,7 @@ public final class RegionUtil {
* @param color The color of the border * @param color The color of the border
* @param region The region that should have the border * @param region The region that should have the border
* @param sheet The sheet that the region is on. * @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) { public static void setBottomBorderColor(int color, CellRangeAddress region, Sheet sheet) {
int colStart = region.getFirstColumn(); int colStart = region.getFirstColumn();
@ -245,26 +302,30 @@ public final class RegionUtil {
} }
/** /**
* Sets the top border for a region of cells by manipulating the cell style of the individual * Sets the top border style for a region of cells by manipulating the cell style of the individual
* cells on the top * cells on the top
* *
* @param border The new border * @param border The new border
* @param region The region that should have the border * @param region The region that should have the border
* @param workbook The workbook that the region is on. * @param workbook The workbook that the region is on.
* @param sheet The sheet that the region is on. * @param sheet The sheet that the region is on.
* @deprecated 3.15 beta 2. Use {@link #setBorderTop(int, CellRangeAddress, Sheet)}. * @deprecated 3.15 beta 2. Use {@link #setBorderTop(BorderStyle, CellRangeAddress, Sheet)}.
*/ */
@Removal(version="3.17")
public static void setBorderTop(int border, CellRangeAddress region, Sheet sheet, Workbook workbook) { public static void setBorderTop(int border, CellRangeAddress region, Sheet sheet, Workbook workbook) {
setBorderTop(border, region, sheet); setBorderTop(border, region, sheet);
} }
/** /**
* Sets the top border for a region of cells by manipulating the cell style of the individual * Sets the top border style for a region of cells by manipulating the cell style of the individual
* cells on the top * cells on the top
* *
* @param border The new border * @param border The new border
* @param region The region that should have the border * @param region The region that should have the border
* @param sheet The sheet that the region is on. * @param sheet The sheet that the region is on.
* @since POI 3.15 beta 2
* @deprecated 3.16 beta 1. Use {@link #setBorderTop(BorderStyle, CellRangeAddress, Sheet)}.
*/ */
@Removal(version="3.18")
public static void setBorderTop(int border, CellRangeAddress region, Sheet sheet) { public static void setBorderTop(int border, CellRangeAddress region, Sheet sheet) {
int colStart = region.getFirstColumn(); int colStart = region.getFirstColumn();
int colEnd = region.getLastColumn(); int colEnd = region.getLastColumn();
@ -275,6 +336,18 @@ public final class RegionUtil {
cps.setProperty(row, 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) {
setBorderTop(border.getCode(), region, sheet);
}
/** /**
* Sets the top border color for a region of cells by manipulating the cell style of the individual * Sets the top border color for a region of cells by manipulating the cell style of the individual
@ -286,6 +359,7 @@ public final class RegionUtil {
* @param sheet The sheet that the region is on. * @param sheet The sheet that the region is on.
* @deprecated 3.15 beta 2. Use {@link #setTopBorderColor(int, CellRangeAddress, Sheet)}. * @deprecated 3.15 beta 2. Use {@link #setTopBorderColor(int, CellRangeAddress, Sheet)}.
*/ */
@Removal(version="3.17")
public static void setTopBorderColor(int color, CellRangeAddress region, Sheet sheet, Workbook workbook) { public static void setTopBorderColor(int color, CellRangeAddress region, Sheet sheet, Workbook workbook) {
setTopBorderColor(color, region, sheet); setTopBorderColor(color, region, sheet);
} }
@ -296,6 +370,7 @@ public final class RegionUtil {
* @param color The color of the border * @param color The color of the border
* @param region The region that should have the border * @param region The region that should have the border
* @param sheet The sheet that the region is on. * @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) { public static void setTopBorderColor(int color, CellRangeAddress region, Sheet sheet) {
int colStart = region.getFirstColumn(); int colStart = region.getFirstColumn();

View File

@ -17,8 +17,14 @@
package org.apache.poi.ss.util; package org.apache.poi.ss.util;
import static org.junit.Assert.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
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.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.junit.After; import org.junit.After;
@ -32,7 +38,10 @@ import java.io.IOException;
*/ */
public final class TestRegionUtil { public final class TestRegionUtil {
private static final CellRangeAddress A1C3 = new CellRangeAddress(0, 2, 0, 2); private static final CellRangeAddress A1C3 = new CellRangeAddress(0, 2, 0, 2);
private static short THIN = BorderStyle.THIN.getCode(); private static final BorderStyle NONE = BorderStyle.NONE;
private static final BorderStyle THIN = BorderStyle.THIN;
private static final int RED = IndexedColors.RED.getIndex();
private static final int DEFAULT_COLOR = 0;
private Workbook wb; private Workbook wb;
private Sheet sheet; private Sheet sheet;
@ -47,42 +56,108 @@ public final class TestRegionUtil {
wb.close(); wb.close();
} }
// TODO: fill this in with meaningful unit tests private CellStyle getCellStyle(int rowIndex, int columnIndex) {
// Right now this just makes sure that RegionUtil is compiled into poi schemas Row row = sheet.getRow(rowIndex);
// and that the code doesn't run in an infinite loop. if (row == null) row = sheet.createRow(rowIndex);
// Don't spend too much time getting this unit test to work as this class Cell cell = row.getCell(columnIndex);
// will likely be replaced by CellStyleTemplate soon. if (cell == null) cell = row.createCell(columnIndex);
return cell.getCellStyle();
}
@Test @Test
public void setBorderTop() { public void setBorderTop() {
assertEquals(NONE, getCellStyle(0, 0).getBorderTopEnum());
assertEquals(NONE, getCellStyle(0, 1).getBorderTopEnum());
assertEquals(NONE, getCellStyle(0, 2).getBorderTopEnum());
RegionUtil.setBorderTop(THIN, A1C3, sheet); RegionUtil.setBorderTop(THIN, A1C3, sheet);
assertEquals(THIN, getCellStyle(0, 0).getBorderTopEnum());
assertEquals(THIN, getCellStyle(0, 1).getBorderTopEnum());
assertEquals(THIN, getCellStyle(0, 2).getBorderTopEnum());
} }
@Test @Test
public void setBorderBottom() { public void setBorderBottom() {
assertEquals(NONE, getCellStyle(2, 0).getBorderBottomEnum());
assertEquals(NONE, getCellStyle(2, 1).getBorderBottomEnum());
assertEquals(NONE, getCellStyle(2, 2).getBorderBottomEnum());
RegionUtil.setBorderBottom(THIN, A1C3, sheet); RegionUtil.setBorderBottom(THIN, A1C3, sheet);
assertEquals(THIN, getCellStyle(2, 0).getBorderBottomEnum());
assertEquals(THIN, getCellStyle(2, 1).getBorderBottomEnum());
assertEquals(THIN, getCellStyle(2, 2).getBorderBottomEnum());
} }
@Test @Test
public void setBorderRight() { public void setBorderRight() {
assertEquals(NONE, getCellStyle(0, 2).getBorderRightEnum());
assertEquals(NONE, getCellStyle(1, 2).getBorderRightEnum());
assertEquals(NONE, getCellStyle(2, 2).getBorderRightEnum());
RegionUtil.setBorderRight(THIN, A1C3, sheet); RegionUtil.setBorderRight(THIN, A1C3, sheet);
assertEquals(THIN, getCellStyle(0, 2).getBorderRightEnum());
assertEquals(THIN, getCellStyle(1, 2).getBorderRightEnum());
assertEquals(THIN, getCellStyle(2, 2).getBorderRightEnum());
} }
@Test @Test
public void setBorderLeft() { public void setBorderLeft() {
assertEquals(NONE, getCellStyle(0, 0).getBorderLeftEnum());
assertEquals(NONE, getCellStyle(1, 0).getBorderLeftEnum());
assertEquals(NONE, getCellStyle(2, 0).getBorderLeftEnum());
RegionUtil.setBorderLeft(THIN, A1C3, sheet); RegionUtil.setBorderLeft(THIN, A1C3, sheet);
assertEquals(THIN, getCellStyle(0, 0).getBorderLeftEnum());
assertEquals(THIN, getCellStyle(1, 0).getBorderLeftEnum());
assertEquals(THIN, getCellStyle(2, 0).getBorderLeftEnum());
} }
@Test @Test
public void setTopBorderColor() { public void setTopBorderColor() {
RegionUtil.setTopBorderColor(THIN, A1C3, sheet); assertEquals(DEFAULT_COLOR, getCellStyle(0, 0).getTopBorderColor());
assertEquals(DEFAULT_COLOR, getCellStyle(0, 1).getTopBorderColor());
assertEquals(DEFAULT_COLOR, getCellStyle(0, 2).getTopBorderColor());
RegionUtil.setTopBorderColor(RED, A1C3, sheet);
assertEquals(RED, getCellStyle(0, 0).getTopBorderColor());
assertEquals(RED, getCellStyle(0, 1).getTopBorderColor());
assertEquals(RED, getCellStyle(0, 2).getTopBorderColor());
} }
@Test @Test
public void setBottomBorderColor() { public void setBottomBorderColor() {
RegionUtil.setBottomBorderColor(THIN, A1C3, sheet); assertEquals(DEFAULT_COLOR, getCellStyle(2, 0).getBottomBorderColor());
assertEquals(DEFAULT_COLOR, getCellStyle(2, 1).getBottomBorderColor());
assertEquals(DEFAULT_COLOR, getCellStyle(2, 2).getBottomBorderColor());
RegionUtil.setBottomBorderColor(RED, A1C3, sheet);
assertEquals(RED, getCellStyle(2, 0).getBottomBorderColor());
assertEquals(RED, getCellStyle(2, 1).getBottomBorderColor());
assertEquals(RED, getCellStyle(2, 2).getBottomBorderColor());
} }
@Test @Test
public void setRightBorderColor() { public void setRightBorderColor() {
RegionUtil.setRightBorderColor(THIN, A1C3, sheet); assertEquals(DEFAULT_COLOR, getCellStyle(0, 2).getRightBorderColor());
assertEquals(DEFAULT_COLOR, getCellStyle(1, 2).getRightBorderColor());
assertEquals(DEFAULT_COLOR, getCellStyle(2, 2).getRightBorderColor());
RegionUtil.setRightBorderColor(RED, A1C3, sheet);
assertEquals(RED, getCellStyle(0, 2).getRightBorderColor());
assertEquals(RED, getCellStyle(1, 2).getRightBorderColor());
assertEquals(RED, getCellStyle(2, 2).getRightBorderColor());
} }
@Test @Test
public void setLeftBorderColor() { public void setLeftBorderColor() {
RegionUtil.setLeftBorderColor(THIN, A1C3, sheet); assertEquals(DEFAULT_COLOR, getCellStyle(0, 0).getLeftBorderColor());
assertEquals(DEFAULT_COLOR, getCellStyle(1, 0).getLeftBorderColor());
assertEquals(DEFAULT_COLOR, getCellStyle(2, 0).getLeftBorderColor());
RegionUtil.setLeftBorderColor(RED, A1C3, sheet);
assertEquals(RED, getCellStyle(0, 0).getLeftBorderColor());
assertEquals(RED, getCellStyle(1, 0).getLeftBorderColor());
assertEquals(RED, getCellStyle(2, 0).getLeftBorderColor());
}
@Test
public void bordersCanBeAddedToNonExistantCells() {
RegionUtil.setBorderTop(THIN, A1C3, sheet);
assertEquals(THIN, getCellStyle(0, 0).getBorderTopEnum());
assertEquals(THIN, getCellStyle(0, 1).getBorderTopEnum());
assertEquals(THIN, getCellStyle(0, 2).getBorderTopEnum());
}
@Test
public void borderColorsCanBeAddedToNonExistantCells() {
RegionUtil.setTopBorderColor(RED, A1C3, sheet);
assertEquals(RED, getCellStyle(0, 0).getTopBorderColor());
assertEquals(RED, getCellStyle(0, 1).getTopBorderColor());
assertEquals(RED, getCellStyle(0, 2).getTopBorderColor());
} }
} }