Fix parser invalid index error that occurred when a field name was the same as an Excel function name. EPPlus treated the field name as a 'Function' even if the name was not followed by a left paranthesis to enclose the function arguments following the 'Function' name. We now treat the field name as a 'Name' rather than as a 'Function' when no left parathensis follows the field name. This is true even if the field name is the same as an Excel function name.
diff --git a/EPPlus/FormulaParsing/LexicalAnalysis/SourceCodeTokenizer.cs b/EPPlus/FormulaParsing/LexicalAnalysis/SourceCodeTokenizer.cs index a0d5d47..b8265a1 100644 --- a/EPPlus/FormulaParsing/LexicalAnalysis/SourceCodeTokenizer.cs +++ b/EPPlus/FormulaParsing/LexicalAnalysis/SourceCodeTokenizer.cs
@@ -217,6 +217,24 @@ token.TokenType = TokenType.NameValue; } } + else if (token.TokenType == TokenType.Function) + { + if (i < context.Result.Count - 1) + { + if (context.Result[i + 1].TokenType == TokenType.OpeningParenthesis) + { + token.TokenType = TokenType.Function; + } + else + { + token.TokenType = TokenType.Unrecognized; + } + } + else + { + token.TokenType = TokenType.Unrecognized; + } + } else if ((token.TokenType == TokenType.Operator || token.TokenType == TokenType.Negator) && i < context.Result.Count - 1 && (token.Value=="+" || token.Value=="-")) {