diff --git a/ClosedXML/Excel/CalcEngine/CalcEngine.cs b/ClosedXML/Excel/CalcEngine/CalcEngine.cs index 290208c..1738b2f 100644 --- a/ClosedXML/Excel/CalcEngine/CalcEngine.cs +++ b/ClosedXML/Excel/CalcEngine/CalcEngine.cs @@ -624,12 +624,15 @@ val = ParseDouble(lit, _ci); } - // build token - _token = new Token(val, TKID.ATOM, TKTYPE.LITERAL); + if (c != ':') + { + // build token + _token = new Token(val, TKID.ATOM, TKTYPE.LITERAL); - // advance pointer and return - _ptr += i; - return; + // advance pointer and return + _ptr += i; + return; + } } // parse strings diff --git a/ClosedXML_Tests/Excel/Misc/FormulaTests.cs b/ClosedXML_Tests/Excel/Misc/FormulaTests.cs index 4f4b5ff..a1e1a66 100644 --- a/ClosedXML_Tests/Excel/Misc/FormulaTests.cs +++ b/ClosedXML_Tests/Excel/Misc/FormulaTests.cs @@ -4,9 +4,6 @@ namespace ClosedXML_Tests.Excel { - /// - /// Summary description for UnitTest1 - /// [TestFixture] public class FormulaTests { @@ -83,5 +80,39 @@ Assert.AreEqual(actual, "B"); } } + + [Test] + public void FormulaThatReferencesEntireRow() + { + using (var wb = new XLWorkbook()) + { + var ws = wb.AddWorksheet("Sheet1"); + ws.FirstCell().Value = 1; + ws.FirstCell().CellRight().Value = 2; + ws.FirstCell().CellRight(5).Value = 3; + + ws.FirstCell().CellBelow().FormulaA1 = "=SUM(1:1)"; + + var actual = ws.FirstCell().CellBelow().Value; + Assert.AreEqual(6, actual); + } + } + + [Test] + public void FormulaThatReferencesEntireColumn() + { + using (var wb = new XLWorkbook()) + { + var ws = wb.AddWorksheet("Sheet1"); + ws.FirstCell().Value = 1; + ws.FirstCell().CellBelow().Value = 2; + ws.FirstCell().CellBelow(5).Value = 3; + + ws.FirstCell().CellRight().FormulaA1 = "=SUM(A:A)"; + + var actual = ws.FirstCell().CellRight().Value; + Assert.AreEqual(6, actual); + } + } } }