当前位置: 首页>>代码示例>>C#>>正文


C# HSSFFormulaEvaluator.ClearAllCachedResultValues方法代码示例

本文整理汇总了C#中NPOI.HSSF.UserModel.HSSFFormulaEvaluator.ClearAllCachedResultValues方法的典型用法代码示例。如果您正苦于以下问题:C# HSSFFormulaEvaluator.ClearAllCachedResultValues方法的具体用法?C# HSSFFormulaEvaluator.ClearAllCachedResultValues怎么用?C# HSSFFormulaEvaluator.ClearAllCachedResultValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NPOI.HSSF.UserModel.HSSFFormulaEvaluator的用法示例。


在下文中一共展示了HSSFFormulaEvaluator.ClearAllCachedResultValues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestEvaluateMissingArgs

        public void TestEvaluateMissingArgs()
        {
            HSSFWorkbook wb = new HSSFWorkbook();
            HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
            ISheet sheet = wb.CreateSheet("Sheet1");
            ICell cell = sheet.CreateRow(0).CreateCell(0);

            cell.CellFormula=("if(true,)");
            fe.ClearAllCachedResultValues();
            CellValue cv;
            try
            {
                cv = fe.Evaluate(cell);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.Message);
                throw new AssertionException("Missing args Evaluation not implemented (bug 43354");
            }
            // MissingArg -> BlankEval -> zero (as formula result)
            Assert.AreEqual(0.0, cv.NumberValue, 0.0);

            // MissingArg -> BlankEval -> empty string (in concatenation)
            cell.CellFormula=("\"abc\"&if(true,)");
            fe.ClearAllCachedResultValues();
            Assert.AreEqual("abc", fe.Evaluate(cell).StringValue);
        }
开发者ID:hanwangkun,项目名称:npoi,代码行数:27,代码来源:TestMissingArgEval.cs

示例2: TestEvaluateInSheetExample2

        public void TestEvaluateInSheetExample2()
        {
            HSSFWorkbook wb = new HSSFWorkbook();
            ISheet sheet = wb.CreateSheet("Sheet1");
            IRow row = sheet.CreateRow(0);

            sheet.CreateRow(1).CreateCell(0).SetCellValue(0.08d);
            sheet.CreateRow(2).CreateCell(0).SetCellValue(-40000d);
            sheet.CreateRow(3).CreateCell(0).SetCellValue(8000d);
            sheet.CreateRow(4).CreateCell(0).SetCellValue(9200d);
            sheet.CreateRow(5).CreateCell(0).SetCellValue(10000d);
            sheet.CreateRow(6).CreateCell(0).SetCellValue(12000d);
            sheet.CreateRow(7).CreateCell(0).SetCellValue(14500d);

            ICell cell = row.CreateCell(8);
            HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);

            // Enumeration
            cell.CellFormula = ("NPV(A2, A4,A5,A6,A7,A8)+A3");
            fe.ClearAllCachedResultValues();
            fe.EvaluateFormulaCell(cell);
            double res = cell.NumericCellValue;
            Assert.AreEqual(1922.06d, Math.Round(res * 100d) / 100d);

            // Range
            cell.CellFormula = ("NPV(A2, A4:A8)+A3");

            fe.ClearAllCachedResultValues();
            fe.EvaluateFormulaCell(cell);
            res = cell.NumericCellValue;
            Assert.AreEqual(1922.06d, Math.Round(res * 100d) / 100d);
        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:32,代码来源:TestNpv.cs

示例3: TestCountFuncs

        public void TestCountFuncs()
        {
            HSSFWorkbook wb = new HSSFWorkbook();
            HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
            ISheet sheet = wb.CreateSheet("Sheet1");
            ICell cell = sheet.CreateRow(0).CreateCell(0);

            cell.CellFormula=("COUNT(C5,,,,)"); // 4 missing args, C5 is blank 
            Assert.AreEqual(4.0, fe.Evaluate(cell).NumberValue, 0.0);

            cell.CellFormula=("COUNTA(C5,,)"); // 2 missing args, C5 is blank 
            fe.ClearAllCachedResultValues();
            Assert.AreEqual(2.0, fe.Evaluate(cell).NumberValue, 0.0);
        }
开发者ID:hanwangkun,项目名称:npoi,代码行数:14,代码来源:TestMissingArgEval.cs

示例4: TestEvaluateInSheet

        public void TestEvaluateInSheet()
        {
            HSSFWorkbook wb = new HSSFWorkbook();
            ISheet sheet = wb.CreateSheet("Sheet1");
            IRow row = sheet.CreateRow(0);

            row.CreateCell(0).SetCellValue(-4000d);
            row.CreateCell(1).SetCellValue(1200d);
            row.CreateCell(2).SetCellValue(1410d);
            row.CreateCell(3).SetCellValue(1875d);
            row.CreateCell(4).SetCellValue(1050d);

            ICell cell = row.CreateCell(5);
            cell.CellFormula = ("IRR(A1:E1)");

            HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
            fe.ClearAllCachedResultValues();
            fe.EvaluateFormulaCell(cell);
            double res = cell.NumericCellValue;
            Assert.AreEqual(0.143d, Math.Round(res * 1000d) / 1000d);
        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:21,代码来源:TestIrr.cs

示例5: TestEvaluateInSheet

        public void TestEvaluateInSheet()
        {
            IWorkbook wb = new HSSFWorkbook();
            ISheet sheet = wb.CreateSheet("Sheet1");
            IRow row = sheet.CreateRow(0);

            row.CreateCell(0).SetCellValue(-7500d);
            row.CreateCell(1).SetCellValue(3000d);
            row.CreateCell(2).SetCellValue(5000d);
            row.CreateCell(3).SetCellValue(1200d);
            row.CreateCell(4).SetCellValue(4000d);

            row.CreateCell(5).SetCellValue(0.05d);
            row.CreateCell(6).SetCellValue(0.08d);

            ICell cell = row.CreateCell(7);
            cell.CellFormula = (/*setter*/"MIRR(A1:E1, F1, G1)");

            HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
            fe.ClearAllCachedResultValues();
            fe.EvaluateFormulaCell(cell);
            double res = cell.NumericCellValue;
            Assert.AreEqual(0.18736225093, res, 0.00000001);
        }
开发者ID:asd1355215911,项目名称:npoi,代码行数:24,代码来源:TestMirr.cs

示例6: TestIntermediateCircularReferenceResults_bug46898

        public void TestIntermediateCircularReferenceResults_bug46898()
        {
            HSSFWorkbook wb = new HSSFWorkbook();
            ISheet sheet = wb.CreateSheet("Sheet1");

            IRow row = sheet.CreateRow(0);

            ICell cellA1 = row.CreateCell(0);
            ICell cellB1 = row.CreateCell(1);
            ICell cellC1 = row.CreateCell(2);
            ICell cellD1 = row.CreateCell(3);
            ICell cellE1 = row.CreateCell(4);

            cellA1.CellFormula = ("IF(FALSE, 1+B1, 42)");
            cellB1.CellFormula = ("1+C1");
            cellC1.CellFormula = ("1+D1");
            cellD1.CellFormula = ("1+E1");
            cellE1.CellFormula = ("1+A1");

            HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
            CellValue cv;

            // Happy day flow - Evaluate A1 first
            cv = fe.Evaluate(cellA1);
            Assert.AreEqual(CellType.NUMERIC, cv.CellType);
            Assert.AreEqual(42.0, cv.NumberValue, 0.0);
            cv = fe.Evaluate(cellB1); // no circ-ref-error because A1 result is cached
            Assert.AreEqual(CellType.NUMERIC, cv.CellType);
            Assert.AreEqual(46.0, cv.NumberValue, 0.0);

            // Show the bug - Evaluate another cell from the loop first
            fe.ClearAllCachedResultValues();
            cv = fe.Evaluate(cellB1);
            if ((int)cv.CellType == ErrorEval.CIRCULAR_REF_ERROR.ErrorCode)
            {
                throw new AssertionException("Identified bug 46898");
            }
            Assert.AreEqual(CellType.NUMERIC, cv.CellType);
            Assert.AreEqual(46.0, cv.NumberValue, 0.0);

            // start Evaluation on another cell
            fe.ClearAllCachedResultValues();
            cv = fe.Evaluate(cellE1);
            Assert.AreEqual(CellType.NUMERIC, cv.CellType);
            Assert.AreEqual(43.0, cv.NumberValue, 0.0);


        }
开发者ID:xoposhiy,项目名称:npoi,代码行数:48,代码来源:TestCircularReferences.cs


注:本文中的NPOI.HSSF.UserModel.HSSFFormulaEvaluator.ClearAllCachedResultValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。