EPPlus icon indicating copy to clipboard operation
EPPlus copied to clipboard

Expanding a table does not expand the formula

Open samuKara opened this issue 4 years ago • 2 comments

    [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.

samuKara avatar Mar 04 '21 12:03 samuKara

No, this is currently not done in the insert methods. I'll add this as an enhancement.

JanKallman avatar Mar 04 '21 14:03 JanKallman

@JanKallman any updates on this one?

SeanFeldman avatar Jan 29 '23 20:01 SeanFeldman