Skip to content

Commit

Permalink
fix wrong calculation of IFERROR and Match function when missing argu…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
Yvees committed Sep 1, 2020
1 parent d523ac9 commit fa5aab3
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 @@ -202,6 +202,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 fa5aab3

Please sign in to comment.