Skip to content

Commit

Permalink
Merge pull request #408 from Yvees/master
Browse files Browse the repository at this point in the history
Bug Fix: Wrong calculation of IFERROR and Match function
  • Loading branch information
tonyqus authored Dec 8, 2020
2 parents 53f62a1 + fa5aab3 commit 317da2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main/SS/Formula/Atp/IfError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ private static ValueEval EvaluateInternal(ValueEval arg, ValueEval iferror, int
arg = WorkbookEvaluator.DereferenceResult(arg, srcCellRow, srcCellCol);
if (arg is ErrorEval)
{
return iferror;
//if the 2nd argument is missing, use an empty string as default
if (iferror is MissingArgEval)
{
return new StringEval(string.Empty);
}
else
{
return iferror;
}
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions main/SS/Formula/Functions/Match.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ private static double EvaluateMatchTypeArg(ValueEval arg, int srcCellRow, int sr
// if the string Parses as a number, it Is OK
return d;
}
//if the 3rd argument is missing, use the default value
if (match_type is MissingArgEval)
{
return 1d;
}
throw new Exception("Unexpected match_type type (" + match_type.GetType().Name + ")");
}

Expand Down

0 comments on commit 317da2b

Please sign in to comment.