Exemplo n.º 1
0
        public void Bug47737()
        {
            XSSFWorkbook wb = XSSFTestDataSamples.OpenSampleWorkbook("47737.xlsx");

            Assert.AreEqual(2, wb.NumberOfNames);
            Assert.IsNotNull(wb.GetCalculationChain());

            XSSFName nm0 = (XSSFName)wb.GetNameAt(0);

            Assert.IsTrue(nm0.GetCTName().IsSetLocalSheetId());
            Assert.AreEqual(0u, nm0.GetCTName().localSheetId);

            XSSFName nm1 = (XSSFName)wb.GetNameAt(1);

            Assert.IsTrue(nm1.GetCTName().IsSetLocalSheetId());
            Assert.AreEqual(1u, nm1.GetCTName().localSheetId);

            wb.RemoveSheetAt(0);
            Assert.AreEqual(1, wb.NumberOfNames);
            XSSFName nm2 = (XSSFName)wb.GetNameAt(0);

            Assert.IsTrue(nm2.GetCTName().IsSetLocalSheetId());
            Assert.AreEqual(0u, nm2.GetCTName().localSheetId);
            //calculation chain is Removed as well
            Assert.IsNull(wb.GetCalculationChain());
        }
Exemplo n.º 2
0
        public void Bug47813()
        {
            XSSFWorkbook wb1 = XSSFTestDataSamples.OpenSampleWorkbook("47813.xlsx");

            Assert.AreEqual(3, wb1.NumberOfSheets);
            Assert.IsNotNull(wb1.GetCalculationChain());

            Assert.AreEqual("Numbers", wb1.GetSheetName(0));
            //the second sheet is of type 'chartsheet'
            Assert.AreEqual("Chart", wb1.GetSheetName(1));
            Assert.IsTrue(wb1.GetSheetAt(1) is XSSFChartSheet);
            Assert.AreEqual("SomeJunk", wb1.GetSheetName(2));

            wb1.RemoveSheetAt(2);
            Assert.AreEqual(2, wb1.NumberOfSheets);
            Assert.IsNull(wb1.GetCalculationChain());

            XSSFWorkbook wb2 = (XSSFWorkbook)XSSFTestDataSamples.WriteOutAndReadBack(wb1);

            Assert.AreEqual(2, wb2.NumberOfSheets);
            Assert.IsNull(wb2.GetCalculationChain());

            Assert.AreEqual("Numbers", wb2.GetSheetName(0));
            Assert.AreEqual("Chart", wb2.GetSheetName(1));

            wb2.Close();
            wb1.Close();
        }
Exemplo n.º 3
0
        public void Test46535()
        {
            XSSFWorkbook wb = XSSFTestDataSamples.OpenSampleWorkbook("46535.xlsx");

            CalculationChain chain = wb.GetCalculationChain();
            //the bean holding the reference to the formula to be deleted
            CT_CalcCell c   = chain.GetCTCalcChain().GetCArray(0);
            int         cnt = chain.GetCTCalcChain().c.Count;

            Assert.AreEqual(10, c.i);
            Assert.AreEqual("E1", c.r);

            ISheet sheet = wb.GetSheet("Test");
            ICell  cell  = sheet.GetRow(0).GetCell(4);

            Assert.AreEqual(CellType.FORMULA, cell.CellType);
            cell.SetCellFormula(null);

            //the count of items is less by one
            c = chain.GetCTCalcChain().GetCArray(0);
            int cnt2 = chain.GetCTCalcChain().c.Count;

            Assert.AreEqual(cnt - 1, cnt2);
            //the first item in the calculation chain is the former second one
            Assert.AreEqual(10, c.i);
            Assert.AreEqual("C1", c.r);

            Assert.AreEqual(CellType.STRING, cell.CellType);
            cell.SetCellValue("ABC");
            Assert.AreEqual(CellType.STRING, cell.CellType);
        }
Exemplo n.º 4
0
        public void RemoveAllFormulas()
        {
            XSSFWorkbook wb = XSSFTestDataSamples.OpenSampleWorkbook("TwoFunctions.xlsx");

            CalculationChain chain = wb.GetCalculationChain();
            //the bean holding the reference to the formula to be deleted
            CT_CalcCell c   = chain.GetCTCalcChain().GetCArray(0);
            int         cnt = chain.GetCTCalcChain().c.Count;

            Assert.AreEqual(1, c.i);
            Assert.AreEqual("A5", c.r);
            Assert.AreEqual(2, cnt);

            ISheet sheet = wb.GetSheet("Sheet1");
            ICell  cell  = sheet.GetRow(4).GetCell(0);

            Assert.AreEqual(CellType.Formula, cell.CellType);
            cell.SetCellFormula(null);

            //the count of items is less by one
            c = chain.GetCTCalcChain().GetCArray(0);
            int cnt2 = chain.GetCTCalcChain().c.Count;

            Assert.AreEqual(cnt - 1, cnt2);
            //the first item in the calculation chain is the former second one
            Assert.AreEqual(1, c.i);
            Assert.AreEqual("A4", c.r);
            Assert.AreEqual(1, cnt2);

            //remove final formula from spread sheet
            ICell cell2 = sheet.GetRow(3).GetCell(0);

            Assert.AreEqual(CellType.Formula, cell2.CellType);
            cell2.SetCellFormula(null);

            //the count of items within the chain should be 0
            int cnt3 = chain.GetCTCalcChain().c.Count;

            Assert.AreEqual(0, cnt3);
        }