assertFalse(ctBorder.isSetTop());
}
+ public void testGetSetBorderThin() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_THIN);\r
+ assertEquals(CellStyle.BORDER_THIN, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.THIN, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
+ public void testGetSetBorderMedium() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);\r
+ assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.MEDIUM, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
+ public void testGetSetBorderThick() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_THICK);\r
+ assertEquals(CellStyle.BORDER_THICK, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.THICK, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
+ public void testGetSetBorderHair() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_HAIR);\r
+ assertEquals(CellStyle.BORDER_HAIR, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.HAIR, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
+ public void testGetSetBorderDotted() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_DOTTED);\r
+ assertEquals(CellStyle.BORDER_DOTTED, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.DOTTED, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
+ public void testGetSetBorderDashed() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_DASHED);\r
+ assertEquals(CellStyle.BORDER_DASHED, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.DASHED, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
+ public void testGetSetBorderDashDot() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT);\r
+ assertEquals(CellStyle.BORDER_DASH_DOT, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.DASH_DOT, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
+ public void testGetSetBorderDashDotDot() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT_DOT);\r
+ assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.DASH_DOT_DOT, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
+ public void testGetSetBorderMediumDashDot() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT);\r
+ assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.MEDIUM_DASH_DOT, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
+ public void testGetSetBorderMediumDashDotDot() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT);\r
+ assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.MEDIUM_DASH_DOT_DOT, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
+ public void testGetSetBorderMediumDashed() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);\r
+ assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.MEDIUM_DASHED, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
+ public void testGetSetBorderSlantDashDot() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_SLANTED_DASH_DOT);\r
+ assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.SLANT_DASH_DOT, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
+ public void testGetSetBorderDouble() {\r
+ cellStyle.setBorderTop(CellStyle.BORDER_DOUBLE);\r
+ assertEquals(CellStyle.BORDER_DOUBLE, cellStyle.getBorderTop());\r
+ int borderId = (int)cellStyle.getCoreXf().getBorderId();\r
+ assertTrue(borderId > 0);\r
+ //check changes in the underlying xml bean\r
+ CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();\r
+ assertEquals(STBorderStyle.DOUBLE, ctBorder.getTop().getStyle());\r
+ }\r
+ \r
public void testGetSetBottomBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getBottomBorderColor());
package org.apache.poi.hssf.usermodel;
-import junit.framework.TestCase;
-import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.util.TempFile;
-
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
+import junit.framework.TestCase;
+
+import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.util.TempFile;
+
/**
* Class to test cell styling functionality
*
c4.setCellStyle(cs2);
assertEquals("style1", c4.getCellStyle().getParentStyle().getUserStyleName());
}
+ \r
+ public void testGetSetBorderHair() {\r
+ HSSFWorkbook wb = openSample("55341_CellStyleBorder.xls");\r
+ HSSFSheet s = wb.getSheetAt(0);\r
+ HSSFCellStyle cs;\r
+ \r
+ cs = s.getRow(0).getCell(0).getCellStyle();\r
+ assertEquals(CellStyle.BORDER_HAIR, cs.getBorderRight());\r
+ \r
+ cs = s.getRow(1).getCell(1).getCellStyle();\r
+ assertEquals(CellStyle.BORDER_DOTTED, cs.getBorderRight());\r
+\r
+ cs = s.getRow(2).getCell(2).getCellStyle();\r
+ assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cs.getBorderRight());\r
+\r
+ cs = s.getRow(3).getCell(3).getCellStyle();\r
+ assertEquals(CellStyle.BORDER_DASHED, cs.getBorderRight());\r
+\r
+ cs = s.getRow(4).getCell(4).getCellStyle();\r
+ assertEquals(CellStyle.BORDER_THIN, cs.getBorderRight());\r
+\r
+ cs = s.getRow(5).getCell(5).getCellStyle();\r
+ assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cs.getBorderRight());\r
+\r
+ cs = s.getRow(6).getCell(6).getCellStyle();\r
+ assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cs.getBorderRight());\r
+\r
+ cs = s.getRow(7).getCell(7).getCellStyle();\r
+ assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cs.getBorderRight());\r
+\r
+ cs = s.getRow(8).getCell(8).getCellStyle();\r
+ assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cs.getBorderRight());\r
+\r
+ cs = s.getRow(9).getCell(9).getCellStyle();\r
+ assertEquals(CellStyle.BORDER_MEDIUM, cs.getBorderRight());\r
+\r
+ cs = s.getRow(10).getCell(10).getCellStyle();\r
+ assertEquals(CellStyle.BORDER_THICK, cs.getBorderRight());\r
+\r
+ cs = s.getRow(11).getCell(11).getCellStyle();\r
+ assertEquals(CellStyle.BORDER_DOUBLE, cs.getBorderRight());\r
+ }\r
}