Beispiel #1
0
        public void TestCloneSheetMultipleTimes()
        {
            Workbook       workbook = GetTestDataProvider().CreateWorkbook();
            CreationHelper factory  = workbook.GetCreationHelper();
            Sheet          sheet    = workbook.CreateSheet("Test Clone");
            Row            row      = sheet.CreateRow(0);
            Cell           cell     = row.CreateCell(0);

            cell.SetCellValue(factory.CreateRichTextString("Clone_test"));
            //Clone the sheet multiple times
            workbook.CloneSheet(0);
            workbook.CloneSheet(0);

            Assert.IsNotNull(workbook.GetSheet("Test Clone"));
            Assert.IsNotNull(workbook.GetSheet("Test Clone (2)"));
            Assert.AreEqual("Test Clone (3)", workbook.GetSheetName(2));
            Assert.IsNotNull(workbook.GetSheet("Test Clone (3)"));

            workbook.RemoveSheetAt(0);
            workbook.RemoveSheetAt(0);
            workbook.RemoveSheetAt(0);
            workbook.CreateSheet("abc ( 123)");
            workbook.CloneSheet(0);
            Assert.AreEqual("abc (124)", workbook.GetSheetName(1));
        }
Beispiel #2
0
        public void TestCloneSheet()
        {
            Workbook       workbook = GetTestDataProvider().CreateWorkbook();
            CreationHelper factory  = workbook.GetCreationHelper();
            Sheet          sheet    = workbook.CreateSheet("Test Clone");
            Row            row      = sheet.CreateRow(0);
            Cell           cell     = row.CreateCell(0);
            Cell           cell2    = row.CreateCell(1);

            cell.SetCellValue(factory.CreateRichTextString("Clone_test"));
            cell2.CellFormula = "SIN(1)";

            Sheet ClonedSheet = workbook.CloneSheet(0);
            Row   ClonedRow   = ClonedSheet.GetRow(0);

            //Check for a good clone
            Assert.AreEqual(ClonedRow.GetCell(0).RichStringCellValue.String, "Clone_test");

            //Check that the cells are not somehow linked
            cell.SetCellValue(factory.CreateRichTextString("Difference Check"));
            cell2.CellFormula = "cos(2)";
            if ("Difference Check".Equals(ClonedRow.GetCell(0).RichStringCellValue.String))
            {
                Assert.Fail("string cell not properly Cloned");
            }
            if ("COS(2)".Equals(ClonedRow.GetCell(1).CellFormula))
            {
                Assert.Fail("formula cell not properly Cloned");
            }
            Assert.AreEqual(ClonedRow.GetCell(0).RichStringCellValue.String, "Clone_test");
            Assert.AreEqual(ClonedRow.GetCell(1).CellFormula, "SIN(1)");
        }
Beispiel #3
0
        public void Test35084()
        {
            Workbook wb = GetTestDataProvider().CreateWorkbook();
            Sheet    s  = wb.CreateSheet("Sheet1");
            Row      r  = s.CreateRow(0);

            r.CreateCell(0).SetCellValue(1);
            r.CreateCell(1).CellFormula = ("A1*2");
            Sheet s1 = wb.CloneSheet(0);

            r = s1.GetRow(0);
            Assert.AreEqual(r.GetCell(0).NumericCellValue, 1, 0, "double"); // sanity check
            Assert.IsNotNull(r.GetCell(1));
            Assert.AreEqual(r.GetCell(1).CellFormula, "A1*2", "formula");
        }