public void TestUpdateCachedFormulaResultFromErrorToNumber_bug46479()
        {
            IWorkbook wb     = _testDataProvider.CreateWorkbook();
            ISheet    sheet  = wb.CreateSheet("Sheet1");
            IRow      row    = sheet.CreateRow(0);
            ICell     cellA1 = row.CreateCell(0);
            ICell     cellB1 = row.CreateCell(1);

            cellB1.SetCellFormula("A1+1");
            IFormulaEvaluator fe = wb.GetCreationHelper().CreateFormulaEvaluator();

            cellA1.SetCellErrorValue((byte)ErrorConstants.ERROR_NAME);
            fe.EvaluateFormulaCell(cellB1);

            cellA1.SetCellValue(2.5);
            fe.NotifyUpdateCell(cellA1);
            try
            {
                fe.EvaluateInCell(cellB1);
            }
            catch (InvalidOperationException e)
            {
                if (e.Message.Equals("Cannot get a numeric value from a error formula cell"))
                {
                    throw new AssertionException("Identified bug 46479a");
                }
            }
            Assert.AreEqual(3.5, cellB1.NumericCellValue, 0.0);
        }
Пример #2
0
        private static void ConfirmResult(IFormulaEvaluator fe, ICell cell, String formulaText, String expectedResult)
        {
            cell.SetCellFormula(formulaText);
            fe.NotifyUpdateCell(cell);
            CellValue result = fe.Evaluate(cell);

            Assert.AreEqual(result.CellType, CellType.String);
            Assert.AreEqual(expectedResult, result.StringValue);
        }
Пример #3
0
        private static void ConfirmError(IFormulaEvaluator fe, ICell cell, String formulaText, ErrorEval expectedError)
        {
            fe.DebugEvaluationOutputForNextEval = true;
            cell.SetCellFormula(formulaText);
            fe.NotifyUpdateCell(cell);
            CellValue result = fe.Evaluate(cell);

            Assert.AreEqual(CellType.Error, result.CellType, "Testing result type for: " + formulaText);
            Assert.AreEqual(expectedError.ErrorString, result.FormatAsString(), "Testing error type for: " + formulaText);
        }