1

I try to use excel template and populate it with some data, template contains headers (С1,С2) and sum row(C3) where is C3 = Sum(C3:C3), then I insert 5 rows and populate with data these rows.

var startCell = worksheet.Cells["C3"].Address;
var lastCell = worksheet.Cells["C3"].Address;

worksheet.Cells["C3"].Formula = $"Sum({startCell}:{lastCell})";

worksheet.InsertRow(3, rowsToInsert);

If I use the same cell(C3) for start and end cell in SUM, and insert rows, EEPlus recalculates formula in a wrong way - result is - SUM(C8), not SUM(C3:C7). Is it possible to get range in the recalculated formula, without set range in initial formula?

Artur Zh
  • 25
  • 3
  • 1
    The way it's worded, you'd have a circular reference. If the formula in C3 is `SUM(C3:C7)`, it would be summing itself. – UndeadBob Feb 11 '17 at 13:53

0 Answers0