public void TestColumn() { CT_Worksheet worksheet = new CT_Worksheet(); CT_Cols cols1 = worksheet.AddNewCols(); CT_Col col1 = cols1.AddNewCol(); col1.min = (1); col1.max = (1); col1.width = (88); col1.hidden = (true); CT_Col col2 = cols1.AddNewCol(); col2.min = (2); col2.max = (3); CT_Cols cols2 = worksheet.AddNewCols(); CT_Col col4 = cols2.AddNewCol(); col4.min = (3); col4.max = (6); // Remember - POI column 0 == OOXML column 1 ColumnHelper helper = new ColumnHelper(worksheet); Assert.IsNotNull(helper.GetColumn(0, false)); Assert.IsNotNull(helper.GetColumn(1, false)); Assert.AreEqual(88.0, helper.GetColumn(0, false).width, 0.0); Assert.AreEqual(0.0, helper.GetColumn(1, false).width, 0.0); Assert.IsTrue(helper.GetColumn(0, false).hidden); Assert.IsFalse(helper.GetColumn(1, false).hidden); Assert.IsNull(helper.GetColumn(99, false)); Assert.IsNotNull(helper.GetColumn(5, false)); }
public void TestAddCleanColIntoCols() { CT_Worksheet worksheet = new CT_Worksheet(); ColumnHelper helper = new ColumnHelper(worksheet); CT_Cols cols1 = new CT_Cols(); CT_Col col1 = cols1.AddNewCol(); col1.min = (1); col1.max = (1); col1.width = (88); col1.hidden = (true); CT_Col col2 = cols1.AddNewCol(); col2.min = (2); col2.max = (3); CT_Col col3 = cols1.AddNewCol(); col3.min = (13); col3.max = (16750); Assert.AreEqual(3, cols1.sizeOfColArray()); CT_Col col4 = cols1.AddNewCol(); col4.min = (8); col4.max = (9); Assert.AreEqual(4, cols1.sizeOfColArray()); // No overlap helper.addCleanColIntoCols(cols1, createCol(4, 5)); Assert.AreEqual(5, cols1.sizeOfColArray()); // Overlaps with 8 - 9 (overlap and after replacements required) CT_Col col6 = createCol(8, 11); col6.hidden = (true); helper.AddCleanColIntoCols(cols1, col6); Assert.AreEqual(6, cols1.sizeOfColArray()); // Overlaps with 8 - 9 (before and overlap replacements required) CT_Col col7 = createCol(6, 8); col7.width = (17.0); helper.AddCleanColIntoCols(cols1, col7); Assert.AreEqual(8, cols1.sizeOfColArray()); // Overlaps with 13 - 16750 (before, overlap and after replacements required) helper.addCleanColIntoCols(cols1, createCol(20, 30)); Assert.AreEqual(10, cols1.sizeOfColArray()); // Overlaps with 20 - 30 (before, overlap and after replacements required) helper.addCleanColIntoCols(cols1, createCol(25, 27)); // TODO - assert something interesting Assert.AreEqual(12, cols1.col.Count); Assert.AreEqual(1u, cols1.GetColArray(0).min); Assert.AreEqual(16750u, cols1.GetColArray(11).max); }
public void TestSortColumns() { //CT_Worksheet worksheet = new CT_Worksheet(); //ColumnHelper helper = new ColumnHelper(worksheet); CT_Cols cols1 = new CT_Cols(); CT_Col col1 = cols1.AddNewCol(); col1.min = (1); col1.max = (1); col1.width = (88); col1.hidden = (true); CT_Col col2 = cols1.AddNewCol(); col2.min = (2); col2.max = (3); CT_Col col3 = cols1.AddNewCol(); col3.min = (13); col3.max = (16750); Assert.AreEqual(3, cols1.sizeOfColArray()); CT_Col col4 = cols1.AddNewCol(); col4.min = (8); col4.max = (11); Assert.AreEqual(4, cols1.sizeOfColArray()); CT_Col col5 = cols1.AddNewCol(); col5.min = (4); col5.max = (5); Assert.AreEqual(5, cols1.sizeOfColArray()); CT_Col col6 = cols1.AddNewCol(); col6.min = (8); col6.max = (9); col6.hidden = (true); CT_Col col7 = cols1.AddNewCol(); col7.min = (6); col7.max = (8); col7.width = (17.0); CT_Col col8 = cols1.AddNewCol(); col8.min = (25); col8.max = (27); CT_Col col9 = cols1.AddNewCol(); col9.min = (20); col9.max = (30); Assert.AreEqual(9, cols1.sizeOfColArray()); Assert.AreEqual(20u, cols1.GetColArray(8).min); Assert.AreEqual(30u, cols1.GetColArray(8).max); ColumnHelper.SortColumns(cols1); Assert.AreEqual(9, cols1.sizeOfColArray()); Assert.AreEqual(25u, cols1.GetColArray(8).min); Assert.AreEqual(27u, cols1.GetColArray(8).max); }
public CT_Col CloneCol(CT_Cols cols, CT_Col col) { CT_Col newCol = cols.AddNewCol(); newCol.min = (uint)(col.min); newCol.max = (uint)(col.max); SetColumnAttributes(col, newCol); return newCol; }
public CT_Col CloneCol(CT_Cols cols, CT_Col col) { CT_Col toCol = cols.AddNewCol(); toCol.min = col.min; toCol.max = col.max; this.SetColumnAttributes(col, toCol); return(toCol); }
public void TestCleanColumns() { CT_Worksheet worksheet = new CT_Worksheet(); CT_Cols cols1 = worksheet.AddNewCols(); CT_Col col1 = cols1.AddNewCol(); col1.min = (1); col1.max = (1); col1.width = (88); col1.hidden = (true); CT_Col col2 = cols1.AddNewCol(); col2.min = (2); col2.max = (3); CT_Cols cols2 = worksheet.AddNewCols(); CT_Col col4 = cols2.AddNewCol(); col4.min = (13); col4.max = (16384); // Test cleaning cols Assert.AreEqual(2, worksheet.sizeOfColsArray()); int count = countColumns(worksheet); Assert.AreEqual(16375, count); // Clean columns and Test a clean worksheet ColumnHelper helper = new ColumnHelper(worksheet); Assert.AreEqual(1, worksheet.sizeOfColsArray()); count = countColumns(worksheet); Assert.AreEqual(16375, count); // Remember - POI column 0 == OOXML column 1 Assert.AreEqual(88.0, helper.GetColumn(0, false).width, 0.0); Assert.IsTrue(helper.GetColumn(0, false).hidden); Assert.AreEqual(0.0, helper.GetColumn(1, false).width, 0.0); Assert.IsFalse(helper.GetColumn(1, false).hidden); }
public void TestMergingOverlappingCols_OVERLAPS_2_MINOR() { XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = (XSSFSheet)wb.CreateSheet("test"); CT_Cols cols = sheet.GetCTWorksheet().GetColsArray(0); CT_Col col = cols.AddNewCol(); col.min = (2 + 1); col.max = (4 + 1); col.width = (20); col.customWidth = (true); sheet.GroupColumn((short)1, (short)3); cols = sheet.GetCTWorksheet().GetColsArray(0); //logger.log(POILogger.DEBUG, "testMergingOverlappingCols_OVERLAPS_2_MINOR/cols:" + cols); Assert.AreEqual(1, cols.GetColArray(0).outlineLevel); Assert.AreEqual(2, cols.GetColArray(0).min); // 1 based Assert.AreEqual(2, cols.GetColArray(0).max); // 1 based Assert.AreEqual(false, cols.GetColArray(0).customWidth); Assert.AreEqual(1, cols.GetColArray(1).outlineLevel); Assert.AreEqual(3, cols.GetColArray(1).min); // 1 based Assert.AreEqual(4, cols.GetColArray(1).max); // 1 based Assert.AreEqual(true, cols.GetColArray(1).customWidth); Assert.AreEqual(0, cols.GetColArray(2).outlineLevel); Assert.AreEqual(5, cols.GetColArray(2).min); // 1 based Assert.AreEqual(5, cols.GetColArray(2).max); // 1 based Assert.AreEqual(true, cols.GetColArray(2).customWidth); Assert.AreEqual(3, cols.sizeOfColArray()); wb = XSSFTestDataSamples.WriteOutAndReadBack(wb, "testMergingOverlappingCols_OVERLAPS_2_MINOR"); sheet = (XSSFSheet)wb.GetSheet("test"); for (int i = 2; i <= 4; i++) { Assert.AreEqual(20 * 256, sheet.GetColumnWidth(i), "Unexpected width of column " + i); } Assert.AreEqual(sheet.DefaultColumnWidth * 256, sheet.GetColumnWidth(1), "Unexpected width of column " + 1); }
public void TestAddCleanColIntoCols() { CT_Worksheet worksheet = new CT_Worksheet(); ColumnHelper helper = new ColumnHelper(worksheet); CT_Cols cols1 = new CT_Cols(); CT_Col col1 = cols1.AddNewCol(); col1.min = (1); col1.max = (1); col1.width = (88); col1.hidden = (true); CT_Col col2 = cols1.AddNewCol(); col2.min = (2); col2.max = (3); CT_Col col3 = cols1.AddNewCol(); col3.min = (13); col3.max = (16750); Assert.AreEqual(3, cols1.sizeOfColArray()); CT_Col col4 = cols1.AddNewCol(); col4.min = (8); col4.max = (9); Assert.AreEqual(4, cols1.sizeOfColArray()); CT_Col col5 = new CT_Col(); col5.min = (4); col5.max = (5); helper.AddCleanColIntoCols(cols1, col5); Assert.AreEqual(5, cols1.sizeOfColArray()); CT_Col col6 = new CT_Col(); col6.min = (8); col6.max = (11); col6.hidden = (true); helper.AddCleanColIntoCols(cols1, col6); Assert.AreEqual(6, cols1.sizeOfColArray()); CT_Col col7 = new CT_Col(); col7.min = (6); col7.max = (8); col7.width = (17.0); helper.AddCleanColIntoCols(cols1, col7); Assert.AreEqual(8, cols1.sizeOfColArray()); CT_Col col8 = new CT_Col(); col8.min = (20); col8.max = (30); helper.AddCleanColIntoCols(cols1, col8); Assert.AreEqual(10, cols1.sizeOfColArray()); CT_Col col9 = new CT_Col(); col9.min = (25); col9.max = (27); helper.AddCleanColIntoCols(cols1, col9); // TODO - assert something interesting Assert.AreEqual(12, cols1.col.Count); Assert.AreEqual(1u, cols1.GetColArray(0).min); Assert.AreEqual(16750u, cols1.GetColArray(11).max); }