Skip to content

Commit

Permalink
Fixes issue i1225 (#1226)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanKallman authored Dec 22, 2023
1 parent 601c74c commit f94ec88
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private CompileResult GetNegatedValue(object value, FormulaRangeAddress addressI
}
else
{
var d = ConvertUtil.GetValueDouble(value, false, true);
var d = ConvertUtil.GetValueDouble(value??0D, false, true);
if (double.IsNaN(d))
{
return CompileResultFactory.Create(ExcelErrorValue.Create(eErrorType.Value), addressInfo);
Expand Down
16 changes: 15 additions & 1 deletion src/EPPlusTest/FormulaParsing/NegatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,19 @@ public void DoubleNegationsWithCells()
Assert.AreEqual(-9.75, ws.Cells["G1"].Value);
}
}
}
[TestMethod]
public void NegateAnEmptyCellShouldReturnZero()
{
using (var p = new ExcelPackage())
{
var ws = p.Workbook.Worksheets.Add("Sheet1");

ws.Cells["A1"].Formula = "-B1";
ws.Calculate();

Assert.AreEqual(0d, ws.Cells["A1"].Value);
}
}

}
}
1 change: 0 additions & 1 deletion src/EPPlusTest/Issues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6069,6 +6069,5 @@ public void VBA_ModuleName()
}
}


}
}

0 comments on commit f94ec88

Please sign in to comment.