Skip to content

Commit

Permalink
Added validation for shared formulas
Browse files Browse the repository at this point in the history
  • Loading branch information
JanKallman committed Feb 20, 2020
1 parent 1fa7559 commit f6b1b1f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/EPPlus/ExcelWorksheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2905,10 +2905,13 @@ private void UpdateRowCellData(StreamWriter sw, string prefix)
}
object v = val._value;
object formula = _formulas.GetValue(cse.Row, cse.Column);
if (formula is int)
if (formula is int sfId)
{
var sfId = (int)formula;
var f = _sharedFormulas[(int)sfId];
if(!_sharedFormulas.ContainsKey(sfId))
{
throw (new InvalidDataException($"SharedFormulaId {sfId} not found on Worksheet {Name} cell {cse.CellAddress}"));
}
var f = _sharedFormulas[sfId];
if (f.Address.IndexOf(':') > 0)
{
if (f.StartCol == cse.Column && f.StartRow == cse.Row)
Expand Down

0 comments on commit f6b1b1f

Please sign in to comment.