EPPlus
EPPlus copied to clipboard
Expanding a table does not expand the formula
[Test]
public void Extend_Table()
{
using (var package = new ExcelPackage(this.excelFile))
{
var ws = package.Workbook.Worksheets.Add("name");
ws.Cells[1, 1].Value = "A";
ws.Cells[1, 2].Value = "B";
ws.Cells[1, 3].Value = "C";
ws.Cells[2, 1].Value = 1;
ws.Cells[2, 2].Value = 1;
ws.Cells[2, 3].Formula = "SUM($A2:$B2)";
ws.Cells[3, 1].Value = 1;
ws.Cells[3, 2].Value = 1;
ws.Cells[3, 3].Formula = "SUM($A3:$B3)";
var range = ws.Cells[1, 1, 3, 3];
ws.Names.Add("range", range);
ws.InsertRow(3, 1, 4);
Assert.That(ws.Cells[2, 3].Formula, Is.Not.Empty); //True
Assert.That(ws.Cells[3, 3].Formula, Is.Not.Empty); //False
Assert.That(ws.Cells[4, 3].Formula, Is.Not.Empty); //True
}
}
That way work fine manual in Excel.
No, this is currently not done in the insert methods. I'll add this as an enhancement.
@JanKallman any updates on this one?