diff --git a/src/EPPlus/ExcelCellBase.cs b/src/EPPlus/ExcelCellBase.cs index a684ab686..ab8098179 100644 --- a/src/EPPlus/ExcelCellBase.cs +++ b/src/EPPlus/ExcelCellBase.cs @@ -1089,7 +1089,7 @@ internal static string UpdateFormulaReferences(string formula, int rowIncrement, if (address == null || (!address.IsValidRowCol() && address.IsName==false)) { - if(i > 0 && GetPrevToken(tokens,i)==")") //Previous token is a function, add the colon. + if(i > 0 && t.TokenType==TokenType.Operator && t.Value==":" && GetPrevToken(tokens,i).TokenType==TokenType.ClosingParenthesis) //Previous token is a function, add the colon. { f += t.Value; } @@ -1125,10 +1125,10 @@ internal static string UpdateFormulaReferences(string formula, int rowIncrement, } } - private static string GetPrevToken(IList tokens, int i) + private static Token GetPrevToken(IList tokens, int i) { while (i > 0 && tokens[--i].TokenType == TokenType.WhiteSpace); - return tokens[i].Value; + return tokens[i]; } private static ExcelAddressBase GetFullAddressFromToken(IList tokens, ref int i)