public void TestGroupRowsExisting() { HSSFWorkbook workbook = OpenSample("NoGutsRecords.xls"); NPOI.SS.UserModel.Sheet s = workbook.GetSheetAt(0); HSSFRow r1 = (HSSFRow)s.GetRow(0); HSSFRow r2 = (HSSFRow)s.GetRow(1); HSSFRow r3 = (HSSFRow)s.GetRow(2); HSSFRow r4 = (HSSFRow)s.GetRow(3); HSSFRow r5 = (HSSFRow)s.GetRow(4); HSSFRow r6 = (HSSFRow)s.GetRow(5); Assert.AreEqual(0, r1.OutlineLevel); Assert.AreEqual(0, r2.OutlineLevel); Assert.AreEqual(0, r3.OutlineLevel); Assert.AreEqual(0, r4.OutlineLevel); Assert.AreEqual(0, r5.OutlineLevel); Assert.AreEqual(0, r6.OutlineLevel); // This used to complain about lacking guts records s.GroupRow(2, 4); Assert.AreEqual(0, r1.OutlineLevel); Assert.AreEqual(0, r2.OutlineLevel); Assert.AreEqual(1, r3.OutlineLevel); Assert.AreEqual(1, r4.OutlineLevel); Assert.AreEqual(1, r5.OutlineLevel); Assert.AreEqual(0, r6.OutlineLevel); // Save and re-Open try { workbook = HSSFTestDataSamples.WriteOutAndReadBack(workbook); } catch (OutOfMemoryException) { throw new AssertFailedException("Identified bug 39903"); } s = workbook.GetSheetAt(0); r1 = (HSSFRow)s.GetRow(0); r2 = (HSSFRow)s.GetRow(1); r3 = (HSSFRow)s.GetRow(2); r4 = (HSSFRow)s.GetRow(3); r5 = (HSSFRow)s.GetRow(4); r6 = (HSSFRow)s.GetRow(5); Assert.AreEqual(0, r1.OutlineLevel); Assert.AreEqual(0, r2.OutlineLevel); Assert.AreEqual(1, r3.OutlineLevel); Assert.AreEqual(1, r4.OutlineLevel); Assert.AreEqual(1, r5.OutlineLevel); Assert.AreEqual(0, r6.OutlineLevel); }
public void TestGroupRows() { HSSFWorkbook workbook = new HSSFWorkbook(); NPOI.SS.UserModel.Sheet s = workbook.CreateSheet(); HSSFRow r1 = (HSSFRow)s.CreateRow(0); HSSFRow r2 = (HSSFRow)s.CreateRow(1); HSSFRow r3 = (HSSFRow)s.CreateRow(2); HSSFRow r4 = (HSSFRow)s.CreateRow(3); HSSFRow r5 = (HSSFRow)s.CreateRow(4); Assert.AreEqual(0, r1.OutlineLevel); Assert.AreEqual(0, r2.OutlineLevel); Assert.AreEqual(0, r3.OutlineLevel); Assert.AreEqual(0, r4.OutlineLevel); Assert.AreEqual(0, r5.OutlineLevel); s.GroupRow(2, 3); Assert.AreEqual(0, r1.OutlineLevel); Assert.AreEqual(0, r2.OutlineLevel); Assert.AreEqual(1, r3.OutlineLevel); Assert.AreEqual(1, r4.OutlineLevel); Assert.AreEqual(0, r5.OutlineLevel); // Save and re-Open workbook = HSSFTestDataSamples.WriteOutAndReadBack(workbook); s = workbook.GetSheetAt(0); r1 = (HSSFRow)s.GetRow(0); r2 = (HSSFRow)s.GetRow(1); r3 = (HSSFRow)s.GetRow(2); r4 = (HSSFRow)s.GetRow(3); r5 = (HSSFRow)s.GetRow(4); Assert.AreEqual(0, r1.OutlineLevel); Assert.AreEqual(0, r2.OutlineLevel); Assert.AreEqual(1, r3.OutlineLevel); Assert.AreEqual(1, r4.OutlineLevel); Assert.AreEqual(0, r5.OutlineLevel); }