public void CircularRefsTest2()
        {
            var ws = _package.Workbook.Worksheets.First();

            ws.Cells["AK5"].Formula = "SUM(AM4:AM6,AO6)";
            ws.Cells["AM4"].Value   = 4;
            ws.Cells["AM5"].Formula = "SUM(AM4)";
            ws.Cells["AM6"].Value   = 2;
            ws.Cells["AO6"].Formula = "SUM(AM4:AM6)";

            var result = _parser.ParseAt("AK5");

            Assert.AreEqual(20d, result);
        }
        public void ParseAtShouldCallExcelDataProvider()
        {
            var excelDataProvider = A.Fake <ExcelDataProvider>();

            A.CallTo(() => excelDataProvider.GetRangeFormula(string.Empty, 1, 1)).Returns("Sum(1,2)");
            var parser = new FormulaParser(excelDataProvider);
            var result = parser.ParseAt("A1");

            Assert.AreEqual(3d, result);
        }
        private static void ParseFormulas(EPPlusExcelDataProvider provider, FormulaParser parser, ExcelWorksheet worksheet)
        {
            var formulas = provider.GetWorksheetFormulas(worksheet.Name);

            foreach (var formulaAddress in formulas.Keys)
            {
                var result = parser.ParseAt(formulaAddress);
                provider.SetCellValue(formulaAddress, result);
            }
        }
Exemplo n.º 4
0
        public void ParseAtShouldCallExcelDataProvider()
        {
            var excelDataProvider = MockRepository.GenerateStub <ExcelDataProvider>();

            excelDataProvider
            .Stub(x => x.GetRangeFormula(string.Empty, 1, 1))
            .Return("Sum(1,2)");
            var parser = new FormulaParser(excelDataProvider);
            var result = parser.ParseAt("A1");

            Assert.AreEqual(3d, result);
        }
        public void LoadTestFromJan()
        {
            var fileInfo = new FileInfo("c:\\temp\\xl\\Kedjor-prestanda test.xlsx");

            using (var package = new ExcelPackage(fileInfo))
            {
                var provider  = new EPPlusExcelDataProvider(package);
                var parser    = new FormulaParser(provider);
                var startTime = DateTime.Now;
                var result    = parser.ParseAt("B1");
                var elapsed   = DateTime.Now.Subtract(startTime);
            }
        }
        public void DefinedNameTest()
        {
            //lopment\ExcelFormulaParser\src\ExcelFormulaParser.EPPlus.Tests\Files\lite
            var fileInfo = new FileInfo("..\\..\\..\\ExcelFormulaParser.EPPlus.Tests\\Files\\lite_olika_namn.xlsx");

            using (var package = new ExcelPackage(fileInfo))
            {
                var provider = new EPPlusExcelDataProvider(package);
                var parser   = new FormulaParser(provider);
                var result   = parser.ParseAt("C4");
                Assert.AreEqual(2d, result);
            }
        }
        public void ChainTest1()
        {
            var cbt = new ChainTestBuilder();

            using (var package = cbt.Build())
            {
                package.SaveAs(new System.IO.FileInfo("c:\\Temp\\chaintest.xlsx"));
                var provider  = new EPPlusExcelDataProvider(package);
                var startTime = DateTime.Now;
                var parser    = new FormulaParser(provider);
                var result    = parser.ParseAt("C1");
                var elapsed   = DateTime.Now.Subtract(startTime);
            }
        }
Exemplo n.º 8
0
        public void ParseAtShouldCallExcelDataProvider()
        {
            var excelDataProvider = MockRepository.GenerateStub <ExcelDataProvider>();

            excelDataProvider
            .Stub(x => x.GetRangeValues("A1"))
            .Return(new List <ExcelCell> {
                new ExcelCell(null, "Sum(1,2)", 0, 0)
            });
            var parser = new FormulaParser(excelDataProvider);
            var result = parser.ParseAt("A1");

            Assert.AreEqual(3d, result);
        }
 public void ParseAtShouldThrowIfAddressIsNull()
 {
     _parser.ParseAt(null);
 }