Minor clean-up in TestXSSFSheet

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@893899 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-12-25 23:43:55 +00:00
parent e39f7c367f
commit 8add64a108
1 changed files with 279 additions and 281 deletions

View File

@ -32,8 +32,6 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
import java.util.Arrays;
public class TestXSSFSheet extends BaseTestSheet { public class TestXSSFSheet extends BaseTestSheet {
@ -194,7 +192,7 @@ public class TestXSSFSheet extends BaseTestSheet {
XSSFComment comment = sheet.createComment(); XSSFComment comment = sheet.createComment();
Cell cell = sheet.createRow(0).createCell((short) 0); Cell cell = sheet.createRow(0).createCell(0);
CommentsTable comments = sheet.getCommentsTable(false); CommentsTable comments = sheet.getCommentsTable(false);
CTComments ctComments = comments.getCTComments(); CTComments ctComments = comments.getCTComments();
@ -223,8 +221,8 @@ public class TestXSSFSheet extends BaseTestSheet {
assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane()); assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
sheet.createFreezePane(3, 6, 10, 10); sheet.createFreezePane(3, 6, 10, 10);
assertEquals(3.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit(), 0.0); assertEquals(3.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getXSplit(), 0.0);
// assertEquals(10, sheet.getTopRow()); // assertEquals(10, sheet.getTopRow());
// assertEquals(10, sheet.getLeftCol()); // assertEquals(10, sheet.getLeftCol());
sheet.createSplitPane(4, 8, 12, 12, 1); sheet.createSplitPane(4, 8, 12, 12, 1);
assertEquals(8.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getYSplit(), 0.0); assertEquals(8.0, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getYSplit(), 0.0);
assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane()); assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
@ -279,7 +277,7 @@ public class TestXSSFSheet extends BaseTestSheet {
XSSFCellStyle cellStyle = new XSSFCellStyle(1, 1, stylesTable); XSSFCellStyle cellStyle = new XSSFCellStyle(1, 1, stylesTable);
assertEquals(1, cellStyle.getFontIndex()); assertEquals(1, cellStyle.getFontIndex());
sheet.setDefaultColumnStyle((short) 3, cellStyle); sheet.setDefaultColumnStyle(3, cellStyle);
assertEquals(1, ctWorksheet.getColsArray(0).getColArray(0).getStyle()); assertEquals(1, ctWorksheet.getColsArray(0).getColArray(0).getStyle());
} }
@ -289,8 +287,8 @@ public class TestXSSFSheet extends BaseTestSheet {
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
//one level //one level
sheet.groupColumn((short) 2, (short) 7); sheet.groupColumn(2, 7);
sheet.groupColumn((short) 10, (short) 11); sheet.groupColumn(10, 11);
CTCols cols = sheet.getCTWorksheet().getColsArray(0); CTCols cols = sheet.getCTWorksheet().getColsArray(0);
assertEquals(2, cols.sizeOfColArray()); assertEquals(2, cols.sizeOfColArray());
CTCol[] colArray = cols.getColArray(); CTCol[] colArray = cols.getColArray();
@ -300,27 +298,27 @@ public class TestXSSFSheet extends BaseTestSheet {
assertEquals(1, colArray[0].getOutlineLevel()); assertEquals(1, colArray[0].getOutlineLevel());
//two level //two level
sheet.groupColumn((short) 1, (short) 2); sheet.groupColumn(1, 2);
cols = sheet.getCTWorksheet().getColsArray(0); cols = sheet.getCTWorksheet().getColsArray(0);
assertEquals(4, cols.sizeOfColArray()); assertEquals(4, cols.sizeOfColArray());
colArray = cols.getColArray(); colArray = cols.getColArray();
assertEquals(2, colArray[1].getOutlineLevel()); assertEquals(2, colArray[1].getOutlineLevel());
//three level //three level
sheet.groupColumn((short) 6, (short) 8); sheet.groupColumn(6, 8);
sheet.groupColumn((short) 2, (short) 3); sheet.groupColumn(2, 3);
cols = sheet.getCTWorksheet().getColsArray(0); cols = sheet.getCTWorksheet().getColsArray(0);
assertEquals(7, cols.sizeOfColArray()); assertEquals(7, cols.sizeOfColArray());
colArray = cols.getColArray(); colArray = cols.getColArray();
assertEquals(3, colArray[1].getOutlineLevel()); assertEquals(3, colArray[1].getOutlineLevel());
assertEquals(3, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol()); assertEquals(3, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
sheet.ungroupColumn((short) 8, (short) 10); sheet.ungroupColumn(8, 10);
colArray = cols.getColArray(); colArray = cols.getColArray();
//assertEquals(3, colArray[1].getOutlineLevel()); //assertEquals(3, colArray[1].getOutlineLevel());
sheet.ungroupColumn((short) 4, (short) 6); sheet.ungroupColumn(4, 6);
sheet.ungroupColumn((short) 2, (short) 2); sheet.ungroupColumn(2, 2);
colArray = cols.getColArray(); colArray = cols.getColArray();
assertEquals(4, colArray.length); assertEquals(4, colArray.length);
assertEquals(2, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol()); assertEquals(2, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
@ -387,227 +385,227 @@ public class TestXSSFSheet extends BaseTestSheet {
* better should really review this! * better should really review this!
*/ */
public void testSetColumnGroupCollapsed(){ public void testSetColumnGroupCollapsed(){
Workbook wb = new XSSFWorkbook(); Workbook wb = new XSSFWorkbook();
XSSFSheet sheet1 =(XSSFSheet) wb.createSheet(); XSSFSheet sheet1 =(XSSFSheet) wb.createSheet();
CTCols cols=sheet1.getCTWorksheet().getColsArray(0); CTCols cols=sheet1.getCTWorksheet().getColsArray(0);
assertEquals(0,cols.sizeOfColArray()); assertEquals(0,cols.sizeOfColArray());
sheet1.groupColumn( (short)4, (short)7 ); sheet1.groupColumn( (short)4, (short)7 );
sheet1.groupColumn( (short)9, (short)12 ); sheet1.groupColumn( (short)9, (short)12 );
assertEquals(2,cols.sizeOfColArray()); assertEquals(2,cols.sizeOfColArray());
assertEquals(false,cols.getColArray(0).isSetHidden()); assertEquals(false,cols.getColArray(0).isSetHidden());
assertEquals(true, cols.getColArray(0).isSetCollapsed()); assertEquals(true, cols.getColArray(0).isSetCollapsed());
assertEquals(5, cols.getColArray(0).getMin()); // 1 based assertEquals(5, cols.getColArray(0).getMin()); // 1 based
assertEquals(8, cols.getColArray(0).getMax()); // 1 based assertEquals(8, cols.getColArray(0).getMax()); // 1 based
assertEquals(false,cols.getColArray(1).isSetHidden()); assertEquals(false,cols.getColArray(1).isSetHidden());
assertEquals(true, cols.getColArray(1).isSetCollapsed()); assertEquals(true, cols.getColArray(1).isSetCollapsed());
assertEquals(10, cols.getColArray(1).getMin()); // 1 based assertEquals(10, cols.getColArray(1).getMin()); // 1 based
assertEquals(13, cols.getColArray(1).getMax()); // 1 based assertEquals(13, cols.getColArray(1).getMax()); // 1 based
sheet1.groupColumn( (short)10, (short)11 ); sheet1.groupColumn( (short)10, (short)11 );
assertEquals(4,cols.sizeOfColArray()); assertEquals(4,cols.sizeOfColArray());
assertEquals(false,cols.getColArray(0).isSetHidden()); assertEquals(false,cols.getColArray(0).isSetHidden());
assertEquals(true, cols.getColArray(0).isSetCollapsed()); assertEquals(true, cols.getColArray(0).isSetCollapsed());
assertEquals(5, cols.getColArray(0).getMin()); // 1 based assertEquals(5, cols.getColArray(0).getMin()); // 1 based
assertEquals(8, cols.getColArray(0).getMax()); // 1 based assertEquals(8, cols.getColArray(0).getMax()); // 1 based
assertEquals(false,cols.getColArray(1).isSetHidden()); assertEquals(false,cols.getColArray(1).isSetHidden());
assertEquals(true, cols.getColArray(1).isSetCollapsed()); assertEquals(true, cols.getColArray(1).isSetCollapsed());
assertEquals(10, cols.getColArray(1).getMin()); // 1 based assertEquals(10, cols.getColArray(1).getMin()); // 1 based
assertEquals(10, cols.getColArray(1).getMax()); // 1 based assertEquals(10, cols.getColArray(1).getMax()); // 1 based
assertEquals(false,cols.getColArray(2).isSetHidden()); assertEquals(false,cols.getColArray(2).isSetHidden());
assertEquals(true, cols.getColArray(2).isSetCollapsed()); assertEquals(true, cols.getColArray(2).isSetCollapsed());
assertEquals(11, cols.getColArray(2).getMin()); // 1 based assertEquals(11, cols.getColArray(2).getMin()); // 1 based
assertEquals(12, cols.getColArray(2).getMax()); // 1 based assertEquals(12, cols.getColArray(2).getMax()); // 1 based
assertEquals(false,cols.getColArray(3).isSetHidden()); assertEquals(false,cols.getColArray(3).isSetHidden());
assertEquals(true, cols.getColArray(3).isSetCollapsed()); assertEquals(true, cols.getColArray(3).isSetCollapsed());
assertEquals(13, cols.getColArray(3).getMin()); // 1 based assertEquals(13, cols.getColArray(3).getMin()); // 1 based
assertEquals(13, cols.getColArray(3).getMax()); // 1 based assertEquals(13, cols.getColArray(3).getMax()); // 1 based
// collapse columns - 1 // collapse columns - 1
sheet1.setColumnGroupCollapsed( (short)5, true ); sheet1.setColumnGroupCollapsed( (short)5, true );
assertEquals(5,cols.sizeOfColArray()); assertEquals(5,cols.sizeOfColArray());
assertEquals(true, cols.getColArray(0).isSetHidden()); assertEquals(true, cols.getColArray(0).isSetHidden());
assertEquals(true, cols.getColArray(0).isSetCollapsed()); assertEquals(true, cols.getColArray(0).isSetCollapsed());
assertEquals(5, cols.getColArray(0).getMin()); // 1 based assertEquals(5, cols.getColArray(0).getMin()); // 1 based
assertEquals(8, cols.getColArray(0).getMax()); // 1 based assertEquals(8, cols.getColArray(0).getMax()); // 1 based
assertEquals(false,cols.getColArray(1).isSetHidden()); assertEquals(false,cols.getColArray(1).isSetHidden());
assertEquals(true, cols.getColArray(1).isSetCollapsed()); assertEquals(true, cols.getColArray(1).isSetCollapsed());
assertEquals(9, cols.getColArray(1).getMin()); // 1 based assertEquals(9, cols.getColArray(1).getMin()); // 1 based
assertEquals(9, cols.getColArray(1).getMax()); // 1 based assertEquals(9, cols.getColArray(1).getMax()); // 1 based
assertEquals(false,cols.getColArray(2).isSetHidden()); assertEquals(false,cols.getColArray(2).isSetHidden());
assertEquals(true, cols.getColArray(2).isSetCollapsed()); assertEquals(true, cols.getColArray(2).isSetCollapsed());
assertEquals(10, cols.getColArray(2).getMin()); // 1 based assertEquals(10, cols.getColArray(2).getMin()); // 1 based
assertEquals(10, cols.getColArray(2).getMax()); // 1 based assertEquals(10, cols.getColArray(2).getMax()); // 1 based
assertEquals(false,cols.getColArray(3).isSetHidden()); assertEquals(false,cols.getColArray(3).isSetHidden());
assertEquals(true, cols.getColArray(3).isSetCollapsed()); assertEquals(true, cols.getColArray(3).isSetCollapsed());
assertEquals(11, cols.getColArray(3).getMin()); // 1 based assertEquals(11, cols.getColArray(3).getMin()); // 1 based
assertEquals(12, cols.getColArray(3).getMax()); // 1 based assertEquals(12, cols.getColArray(3).getMax()); // 1 based
assertEquals(false,cols.getColArray(4).isSetHidden()); assertEquals(false,cols.getColArray(4).isSetHidden());
assertEquals(true, cols.getColArray(4).isSetCollapsed()); assertEquals(true, cols.getColArray(4).isSetCollapsed());
assertEquals(13, cols.getColArray(4).getMin()); // 1 based assertEquals(13, cols.getColArray(4).getMin()); // 1 based
assertEquals(13, cols.getColArray(4).getMax()); // 1 based assertEquals(13, cols.getColArray(4).getMax()); // 1 based
// expand columns - 1 // expand columns - 1
sheet1.setColumnGroupCollapsed( (short)5, false ); sheet1.setColumnGroupCollapsed( (short)5, false );
assertEquals(false,cols.getColArray(0).isSetHidden()); assertEquals(false,cols.getColArray(0).isSetHidden());
assertEquals(true, cols.getColArray(0).isSetCollapsed()); assertEquals(true, cols.getColArray(0).isSetCollapsed());
assertEquals(5, cols.getColArray(0).getMin()); // 1 based assertEquals(5, cols.getColArray(0).getMin()); // 1 based
assertEquals(8, cols.getColArray(0).getMax()); // 1 based assertEquals(8, cols.getColArray(0).getMax()); // 1 based
assertEquals(false,cols.getColArray(1).isSetHidden()); assertEquals(false,cols.getColArray(1).isSetHidden());
assertEquals(false,cols.getColArray(1).isSetCollapsed()); assertEquals(false,cols.getColArray(1).isSetCollapsed());
assertEquals(9, cols.getColArray(1).getMin()); // 1 based assertEquals(9, cols.getColArray(1).getMin()); // 1 based
assertEquals(9, cols.getColArray(1).getMax()); // 1 based assertEquals(9, cols.getColArray(1).getMax()); // 1 based
assertEquals(false,cols.getColArray(2).isSetHidden()); assertEquals(false,cols.getColArray(2).isSetHidden());
assertEquals(true, cols.getColArray(2).isSetCollapsed()); assertEquals(true, cols.getColArray(2).isSetCollapsed());
assertEquals(10, cols.getColArray(2).getMin()); // 1 based assertEquals(10, cols.getColArray(2).getMin()); // 1 based
assertEquals(10, cols.getColArray(2).getMax()); // 1 based assertEquals(10, cols.getColArray(2).getMax()); // 1 based
assertEquals(false,cols.getColArray(3).isSetHidden()); assertEquals(false,cols.getColArray(3).isSetHidden());
assertEquals(true, cols.getColArray(3).isSetCollapsed()); assertEquals(true, cols.getColArray(3).isSetCollapsed());
assertEquals(11, cols.getColArray(3).getMin()); // 1 based assertEquals(11, cols.getColArray(3).getMin()); // 1 based
assertEquals(12, cols.getColArray(3).getMax()); // 1 based assertEquals(12, cols.getColArray(3).getMax()); // 1 based
assertEquals(false,cols.getColArray(4).isSetHidden()); assertEquals(false,cols.getColArray(4).isSetHidden());
assertEquals(true, cols.getColArray(4).isSetCollapsed()); assertEquals(true, cols.getColArray(4).isSetCollapsed());
assertEquals(13, cols.getColArray(4).getMin()); // 1 based assertEquals(13, cols.getColArray(4).getMin()); // 1 based
assertEquals(13, cols.getColArray(4).getMax()); // 1 based assertEquals(13, cols.getColArray(4).getMax()); // 1 based
//collapse - 2 //collapse - 2
sheet1.setColumnGroupCollapsed( (short)9, true ); sheet1.setColumnGroupCollapsed( (short)9, true );
assertEquals(6,cols.sizeOfColArray()); assertEquals(6,cols.sizeOfColArray());
assertEquals(false,cols.getColArray(0).isSetHidden()); assertEquals(false,cols.getColArray(0).isSetHidden());
assertEquals(true, cols.getColArray(0).isSetCollapsed()); assertEquals(true, cols.getColArray(0).isSetCollapsed());
assertEquals(5, cols.getColArray(0).getMin()); // 1 based assertEquals(5, cols.getColArray(0).getMin()); // 1 based
assertEquals(8, cols.getColArray(0).getMax()); // 1 based assertEquals(8, cols.getColArray(0).getMax()); // 1 based
assertEquals(false,cols.getColArray(1).isSetHidden()); assertEquals(false,cols.getColArray(1).isSetHidden());
assertEquals(false,cols.getColArray(1).isSetCollapsed()); assertEquals(false,cols.getColArray(1).isSetCollapsed());
assertEquals(9, cols.getColArray(1).getMin()); // 1 based assertEquals(9, cols.getColArray(1).getMin()); // 1 based
assertEquals(9, cols.getColArray(1).getMax()); // 1 based assertEquals(9, cols.getColArray(1).getMax()); // 1 based
assertEquals(true, cols.getColArray(2).isSetHidden()); assertEquals(true, cols.getColArray(2).isSetHidden());
assertEquals(true, cols.getColArray(2).isSetCollapsed()); assertEquals(true, cols.getColArray(2).isSetCollapsed());
assertEquals(10, cols.getColArray(2).getMin()); // 1 based assertEquals(10, cols.getColArray(2).getMin()); // 1 based
assertEquals(10, cols.getColArray(2).getMax()); // 1 based assertEquals(10, cols.getColArray(2).getMax()); // 1 based
assertEquals(true, cols.getColArray(3).isSetHidden()); assertEquals(true, cols.getColArray(3).isSetHidden());
assertEquals(true, cols.getColArray(3).isSetCollapsed()); assertEquals(true, cols.getColArray(3).isSetCollapsed());
assertEquals(11, cols.getColArray(3).getMin()); // 1 based assertEquals(11, cols.getColArray(3).getMin()); // 1 based
assertEquals(12, cols.getColArray(3).getMax()); // 1 based assertEquals(12, cols.getColArray(3).getMax()); // 1 based
assertEquals(true, cols.getColArray(4).isSetHidden()); assertEquals(true, cols.getColArray(4).isSetHidden());
assertEquals(true, cols.getColArray(4).isSetCollapsed()); assertEquals(true, cols.getColArray(4).isSetCollapsed());
assertEquals(13, cols.getColArray(4).getMin()); // 1 based assertEquals(13, cols.getColArray(4).getMin()); // 1 based
assertEquals(13, cols.getColArray(4).getMax()); // 1 based assertEquals(13, cols.getColArray(4).getMax()); // 1 based
assertEquals(false,cols.getColArray(5).isSetHidden()); assertEquals(false,cols.getColArray(5).isSetHidden());
assertEquals(true, cols.getColArray(5).isSetCollapsed()); assertEquals(true, cols.getColArray(5).isSetCollapsed());
assertEquals(14, cols.getColArray(5).getMin()); // 1 based assertEquals(14, cols.getColArray(5).getMin()); // 1 based
assertEquals(14, cols.getColArray(5).getMax()); // 1 based assertEquals(14, cols.getColArray(5).getMax()); // 1 based
//expand - 2 //expand - 2
sheet1.setColumnGroupCollapsed( (short)9, false ); sheet1.setColumnGroupCollapsed( (short)9, false );
assertEquals(6,cols.sizeOfColArray()); assertEquals(6,cols.sizeOfColArray());
assertEquals(14,cols.getColArray(5).getMin()); assertEquals(14,cols.getColArray(5).getMin());
//outline level 2: the line under ==> collapsed==True //outline level 2: the line under ==> collapsed==True
assertEquals(2,cols.getColArray(3).getOutlineLevel()); assertEquals(2,cols.getColArray(3).getOutlineLevel());
assertEquals(true,cols.getColArray(4).isSetCollapsed()); assertEquals(true,cols.getColArray(4).isSetCollapsed());
assertEquals(false,cols.getColArray(0).isSetHidden()); assertEquals(false,cols.getColArray(0).isSetHidden());
assertEquals(true, cols.getColArray(0).isSetCollapsed()); assertEquals(true, cols.getColArray(0).isSetCollapsed());
assertEquals(5, cols.getColArray(0).getMin()); // 1 based assertEquals(5, cols.getColArray(0).getMin()); // 1 based
assertEquals(8, cols.getColArray(0).getMax()); // 1 based assertEquals(8, cols.getColArray(0).getMax()); // 1 based
assertEquals(false,cols.getColArray(1).isSetHidden()); assertEquals(false,cols.getColArray(1).isSetHidden());
assertEquals(false,cols.getColArray(1).isSetCollapsed()); assertEquals(false,cols.getColArray(1).isSetCollapsed());
assertEquals(9, cols.getColArray(1).getMin()); // 1 based assertEquals(9, cols.getColArray(1).getMin()); // 1 based
assertEquals(9, cols.getColArray(1).getMax()); // 1 based assertEquals(9, cols.getColArray(1).getMax()); // 1 based
assertEquals(false,cols.getColArray(2).isSetHidden()); assertEquals(false,cols.getColArray(2).isSetHidden());
assertEquals(true, cols.getColArray(2).isSetCollapsed()); assertEquals(true, cols.getColArray(2).isSetCollapsed());
assertEquals(10, cols.getColArray(2).getMin()); // 1 based assertEquals(10, cols.getColArray(2).getMin()); // 1 based
assertEquals(10, cols.getColArray(2).getMax()); // 1 based assertEquals(10, cols.getColArray(2).getMax()); // 1 based
assertEquals(true, cols.getColArray(3).isSetHidden()); assertEquals(true, cols.getColArray(3).isSetHidden());
assertEquals(true, cols.getColArray(3).isSetCollapsed()); assertEquals(true, cols.getColArray(3).isSetCollapsed());
assertEquals(11, cols.getColArray(3).getMin()); // 1 based assertEquals(11, cols.getColArray(3).getMin()); // 1 based
assertEquals(12, cols.getColArray(3).getMax()); // 1 based assertEquals(12, cols.getColArray(3).getMax()); // 1 based
assertEquals(false,cols.getColArray(4).isSetHidden()); assertEquals(false,cols.getColArray(4).isSetHidden());
assertEquals(true, cols.getColArray(4).isSetCollapsed()); assertEquals(true, cols.getColArray(4).isSetCollapsed());
assertEquals(13, cols.getColArray(4).getMin()); // 1 based assertEquals(13, cols.getColArray(4).getMin()); // 1 based
assertEquals(13, cols.getColArray(4).getMax()); // 1 based assertEquals(13, cols.getColArray(4).getMax()); // 1 based
assertEquals(false,cols.getColArray(5).isSetHidden()); assertEquals(false,cols.getColArray(5).isSetHidden());
assertEquals(false,cols.getColArray(5).isSetCollapsed()); assertEquals(false,cols.getColArray(5).isSetCollapsed());
assertEquals(14, cols.getColArray(5).getMin()); // 1 based assertEquals(14, cols.getColArray(5).getMin()); // 1 based
assertEquals(14, cols.getColArray(5).getMax()); // 1 based assertEquals(14, cols.getColArray(5).getMax()); // 1 based
//DOCUMENTARE MEGLIO IL DISCORSO DEL LIVELLO //DOCUMENTARE MEGLIO IL DISCORSO DEL LIVELLO
//collapse - 3 //collapse - 3
sheet1.setColumnGroupCollapsed( (short)10, true ); sheet1.setColumnGroupCollapsed( (short)10, true );
assertEquals(6,cols.sizeOfColArray()); assertEquals(6,cols.sizeOfColArray());
assertEquals(false,cols.getColArray(0).isSetHidden()); assertEquals(false,cols.getColArray(0).isSetHidden());
assertEquals(true, cols.getColArray(0).isSetCollapsed()); assertEquals(true, cols.getColArray(0).isSetCollapsed());
assertEquals(5, cols.getColArray(0).getMin()); // 1 based assertEquals(5, cols.getColArray(0).getMin()); // 1 based
assertEquals(8, cols.getColArray(0).getMax()); // 1 based assertEquals(8, cols.getColArray(0).getMax()); // 1 based
assertEquals(false,cols.getColArray(1).isSetHidden()); assertEquals(false,cols.getColArray(1).isSetHidden());
assertEquals(false,cols.getColArray(1).isSetCollapsed()); assertEquals(false,cols.getColArray(1).isSetCollapsed());
assertEquals(9, cols.getColArray(1).getMin()); // 1 based assertEquals(9, cols.getColArray(1).getMin()); // 1 based
assertEquals(9, cols.getColArray(1).getMax()); // 1 based assertEquals(9, cols.getColArray(1).getMax()); // 1 based
assertEquals(false,cols.getColArray(2).isSetHidden()); assertEquals(false,cols.getColArray(2).isSetHidden());
assertEquals(true, cols.getColArray(2).isSetCollapsed()); assertEquals(true, cols.getColArray(2).isSetCollapsed());
assertEquals(10, cols.getColArray(2).getMin()); // 1 based assertEquals(10, cols.getColArray(2).getMin()); // 1 based
assertEquals(10, cols.getColArray(2).getMax()); // 1 based assertEquals(10, cols.getColArray(2).getMax()); // 1 based
assertEquals(true, cols.getColArray(3).isSetHidden()); assertEquals(true, cols.getColArray(3).isSetHidden());
assertEquals(true, cols.getColArray(3).isSetCollapsed()); assertEquals(true, cols.getColArray(3).isSetCollapsed());
assertEquals(11, cols.getColArray(3).getMin()); // 1 based assertEquals(11, cols.getColArray(3).getMin()); // 1 based
assertEquals(12, cols.getColArray(3).getMax()); // 1 based assertEquals(12, cols.getColArray(3).getMax()); // 1 based
assertEquals(false,cols.getColArray(4).isSetHidden()); assertEquals(false,cols.getColArray(4).isSetHidden());
assertEquals(true, cols.getColArray(4).isSetCollapsed()); assertEquals(true, cols.getColArray(4).isSetCollapsed());
assertEquals(13, cols.getColArray(4).getMin()); // 1 based assertEquals(13, cols.getColArray(4).getMin()); // 1 based
assertEquals(13, cols.getColArray(4).getMax()); // 1 based assertEquals(13, cols.getColArray(4).getMax()); // 1 based
assertEquals(false,cols.getColArray(5).isSetHidden()); assertEquals(false,cols.getColArray(5).isSetHidden());
assertEquals(false,cols.getColArray(5).isSetCollapsed()); assertEquals(false,cols.getColArray(5).isSetCollapsed());
assertEquals(14, cols.getColArray(5).getMin()); // 1 based assertEquals(14, cols.getColArray(5).getMin()); // 1 based
assertEquals(14, cols.getColArray(5).getMax()); // 1 based assertEquals(14, cols.getColArray(5).getMax()); // 1 based
//expand - 3 //expand - 3
sheet1.setColumnGroupCollapsed( (short)10, false ); sheet1.setColumnGroupCollapsed( (short)10, false );
assertEquals(6,cols.sizeOfColArray()); assertEquals(6,cols.sizeOfColArray());
assertEquals(false,cols.getColArray(0).getHidden()); assertEquals(false,cols.getColArray(0).getHidden());
assertEquals(false,cols.getColArray(5).getHidden()); assertEquals(false,cols.getColArray(5).getHidden());
assertEquals(false,cols.getColArray(4).isSetCollapsed()); assertEquals(false,cols.getColArray(4).isSetCollapsed());
// write out and give back // write out and give back
// Save and re-load // Save and re-load
wb = XSSFTestDataSamples.writeOutAndReadBack(wb); wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
sheet1 = (XSSFSheet)wb.getSheetAt(0); sheet1 = (XSSFSheet)wb.getSheetAt(0);
assertEquals(6,cols.sizeOfColArray()); assertEquals(6,cols.sizeOfColArray());
assertEquals(false,cols.getColArray(0).isSetHidden()); assertEquals(false,cols.getColArray(0).isSetHidden());
assertEquals(true, cols.getColArray(0).isSetCollapsed()); assertEquals(true, cols.getColArray(0).isSetCollapsed());
assertEquals(5, cols.getColArray(0).getMin()); // 1 based assertEquals(5, cols.getColArray(0).getMin()); // 1 based
assertEquals(8, cols.getColArray(0).getMax()); // 1 based assertEquals(8, cols.getColArray(0).getMax()); // 1 based
assertEquals(false,cols.getColArray(1).isSetHidden()); assertEquals(false,cols.getColArray(1).isSetHidden());
assertEquals(false,cols.getColArray(1).isSetCollapsed()); assertEquals(false,cols.getColArray(1).isSetCollapsed());
assertEquals(9, cols.getColArray(1).getMin()); // 1 based assertEquals(9, cols.getColArray(1).getMin()); // 1 based
assertEquals(9, cols.getColArray(1).getMax()); // 1 based assertEquals(9, cols.getColArray(1).getMax()); // 1 based
assertEquals(false,cols.getColArray(2).isSetHidden()); assertEquals(false,cols.getColArray(2).isSetHidden());
assertEquals(true, cols.getColArray(2).isSetCollapsed()); assertEquals(true, cols.getColArray(2).isSetCollapsed());
assertEquals(10, cols.getColArray(2).getMin()); // 1 based assertEquals(10, cols.getColArray(2).getMin()); // 1 based
assertEquals(10, cols.getColArray(2).getMax()); // 1 based assertEquals(10, cols.getColArray(2).getMax()); // 1 based
assertEquals(false,cols.getColArray(3).isSetHidden()); assertEquals(false,cols.getColArray(3).isSetHidden());
assertEquals(true, cols.getColArray(3).isSetCollapsed()); assertEquals(true, cols.getColArray(3).isSetCollapsed());
assertEquals(11, cols.getColArray(3).getMin()); // 1 based assertEquals(11, cols.getColArray(3).getMin()); // 1 based
assertEquals(12, cols.getColArray(3).getMax()); // 1 based assertEquals(12, cols.getColArray(3).getMax()); // 1 based
assertEquals(false,cols.getColArray(4).isSetHidden()); assertEquals(false,cols.getColArray(4).isSetHidden());
assertEquals(false,cols.getColArray(4).isSetCollapsed()); assertEquals(false,cols.getColArray(4).isSetCollapsed());
assertEquals(13, cols.getColArray(4).getMin()); // 1 based assertEquals(13, cols.getColArray(4).getMin()); // 1 based
assertEquals(13, cols.getColArray(4).getMax()); // 1 based assertEquals(13, cols.getColArray(4).getMax()); // 1 based
assertEquals(false,cols.getColArray(5).isSetHidden()); assertEquals(false,cols.getColArray(5).isSetHidden());
assertEquals(false,cols.getColArray(5).isSetCollapsed()); assertEquals(false,cols.getColArray(5).isSetCollapsed());
assertEquals(14, cols.getColArray(5).getMin()); // 1 based assertEquals(14, cols.getColArray(5).getMin()); // 1 based
assertEquals(14, cols.getColArray(5).getMax()); // 1 based assertEquals(14, cols.getColArray(5).getMax()); // 1 based
} }
/** /**
@ -617,76 +615,76 @@ public class TestXSSFSheet extends BaseTestSheet {
* better should really review this! * better should really review this!
*/ */
public void testSetRowGroupCollapsed(){ public void testSetRowGroupCollapsed(){
Workbook wb = new XSSFWorkbook(); Workbook wb = new XSSFWorkbook();
XSSFSheet sheet1 = (XSSFSheet)wb.createSheet(); XSSFSheet sheet1 = (XSSFSheet)wb.createSheet();
sheet1.groupRow( 5, 14 ); sheet1.groupRow( 5, 14 );
sheet1.groupRow( 7, 14 ); sheet1.groupRow( 7, 14 );
sheet1.groupRow( 16, 19 ); sheet1.groupRow( 16, 19 );
assertEquals(14,sheet1.getPhysicalNumberOfRows()); assertEquals(14,sheet1.getPhysicalNumberOfRows());
assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(7).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(7).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(9).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(9).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(9).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(9).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(14).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(14).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(14).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(14).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(16).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(16).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(16).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(16).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(18).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(18).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden());
//collapsed //collapsed
sheet1.setRowGroupCollapsed( 7, true ); sheet1.setRowGroupCollapsed( 7, true );
assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed());
assertEquals(true, sheet1.getRow(7).getCTRow().isSetHidden()); assertEquals(true, sheet1.getRow(7).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(9).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(9).getCTRow().isSetCollapsed());
assertEquals(true, sheet1.getRow(9).getCTRow().isSetHidden()); assertEquals(true, sheet1.getRow(9).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(14).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(14).getCTRow().isSetCollapsed());
assertEquals(true, sheet1.getRow(14).getCTRow().isSetHidden()); assertEquals(true, sheet1.getRow(14).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(16).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(16).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(16).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(16).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(18).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(18).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden());
//expanded //expanded
sheet1.setRowGroupCollapsed( 7, false ); sheet1.setRowGroupCollapsed( 7, false );
assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed());
assertEquals(true, sheet1.getRow(7).getCTRow().isSetHidden()); assertEquals(true, sheet1.getRow(7).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(9).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(9).getCTRow().isSetCollapsed());
assertEquals(true, sheet1.getRow(9).getCTRow().isSetHidden()); assertEquals(true, sheet1.getRow(9).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(14).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(14).getCTRow().isSetCollapsed());
assertEquals(true, sheet1.getRow(14).getCTRow().isSetHidden()); assertEquals(true, sheet1.getRow(14).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(16).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(16).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(16).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(16).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(18).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(18).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden());
// Save and re-load // Save and re-load
wb = XSSFTestDataSamples.writeOutAndReadBack(wb); wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
sheet1 = (XSSFSheet)wb.getSheetAt(0); sheet1 = (XSSFSheet)wb.getSheetAt(0);
assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(6).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(6).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(7).getCTRow().isSetCollapsed());
assertEquals(true, sheet1.getRow(7).getCTRow().isSetHidden()); assertEquals(true, sheet1.getRow(7).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(9).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(9).getCTRow().isSetCollapsed());
assertEquals(true, sheet1.getRow(9).getCTRow().isSetHidden()); assertEquals(true, sheet1.getRow(9).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(14).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(14).getCTRow().isSetCollapsed());
assertEquals(true, sheet1.getRow(14).getCTRow().isSetHidden()); assertEquals(true, sheet1.getRow(14).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(16).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(16).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(16).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(16).getCTRow().isSetHidden());
assertEquals(false,sheet1.getRow(18).getCTRow().isSetCollapsed()); assertEquals(false,sheet1.getRow(18).getCTRow().isSetCollapsed());
assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden()); assertEquals(false,sheet1.getRow(18).getCTRow().isSetHidden());
} }
/** /**
@ -753,7 +751,7 @@ public class TestXSSFSheet extends BaseTestSheet {
assertEquals(1, col.getMin()); assertEquals(1, col.getMin());
assertEquals(5, col.getMax()); assertEquals(5, col.getMax());
double swidth = 15.77734375; //width of columns in the span double swidth = 15.77734375; //width of columns in the span
assertEquals(swidth, col.getWidth()); assertEquals(swidth, col.getWidth(), 0.0);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
assertEquals((int)(swidth*256), sheet.getColumnWidth(i)); assertEquals((int)(swidth*256), sheet.getColumnWidth(i));
@ -778,7 +776,7 @@ public class TestXSSFSheet extends BaseTestSheet {
assertEquals(5, cols.sizeOfColArray()); assertEquals(5, cols.sizeOfColArray());
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
assertEquals(cw[i]*256, sheet.getColumnWidth(i)); assertEquals(cw[i]*256, sheet.getColumnWidth(i));
assertEquals((double)cw[i], cols.getColArray(i).getWidth()); assertEquals(cw[i], cols.getColArray(i).getWidth(), 0.0);
} }
//serialize and check again //serialize and check again
@ -788,7 +786,7 @@ public class TestXSSFSheet extends BaseTestSheet {
assertEquals(5, cols.sizeOfColArray()); assertEquals(5, cols.sizeOfColArray());
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
assertEquals(cw[i]*256, sheet.getColumnWidth(i)); assertEquals(cw[i]*256, sheet.getColumnWidth(i));
assertEquals((double)cw[i], cols.getColArray(i).getWidth()); assertEquals(cw[i], cols.getColArray(i).getWidth(), 0.0);
} }
} }
@ -897,7 +895,7 @@ public class TestXSSFSheet extends BaseTestSheet {
assertSame(comment1, sheet1.getCommentsTable(true)); assertSame(comment1, sheet1.getCommentsTable(true));
} }
public void testCreateRow(){ public void testCreateRow() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
CTWorksheet wsh = sheet.getCTWorksheet(); CTWorksheet wsh = sheet.getCTWorksheet();