ClosedXML now evaluates formulas!

Sep 25, 2012 at 10:18 PM

cell.Value now evaluates the formulas. This is in an experimental phase so please report any bugs you find. Not all functions are supported so use with caution.

Here's an example of this beauty in action:

            var wb = new XLWorkbook();
            var ws = wb.AddWorksheet("Sheet1");
            ws.Cell("A1").Value = 1;
            ws.Cell("A2").Value = 1;
            ws.Cell("B1").Value = 1;
            ws.Cell("B2").Value = 1;
            ws.Cell("C1").FormulaA1 = "\"The total value is: \" & SUM(A1:B2)";
            var r = ws.Cell("C1").Value;

Prints: "The total value is: 4"

Major props to Bernardo Castilho (Chief Technology Officer at ComponentOne) for his article A Calculation Engine for .NET. I'm still agonizing over the Code Project license because even though it looks like I can use it here, the thing is several pages of legalspeak so the final answer might be "Who knows".