This project has moved and is read-only. For the latest updates, please go here.

problem reading excel sheet cell with formula

Jan 19, 2014 at 3:56 AM
When I try to read excel sheet having formula, I get the result as 0. C4 has the formula as =SUM(C2:C3)
        using (var package = new ExcelPackage(existingFile))
            ExcelWorkbook workBook = package.Workbook;
            var currentWorksheet = workBook.Worksheets.First();
            currentWorksheet.Cells["C2"].Value = 5;
            currentWorksheet.Cells["C3"].Value = 7;
            var c4 = Convert.ToDouble(currentWorksheet.Cells["C4"].Value);
In the above code why is c4 getting the value of zero?

Please help. Thanks
Jan 21, 2014 at 2:46 PM
EPPlus does not have a calculation engine built into it, so it won't calculate a cell's value if it happens to have a formula in it. You can get the formula from the cell via the CellRange.Formula property as opposed to the CellRange.Value property.
Jan 21, 2014 at 8:07 PM
Next version of EPPlus will have a calculation engine. A beta will be available in the near future.