This project has moved. For the latest updates, please go here.
1
Vote

Inserting rows or columns does not update cross-sheet references.

description

When rows or columns are inserted, only references on the sheet being modified are updated. References from other sheets should also be updated when rows or columns are inserted. I have attached a simple test case:
        [TestMethod]
        public void CrossSheetInsertRowsUpdatesReferencesCorrectly()
        {
            using (var package = new ExcelPackage())
            {
                var sheet1 = package.Workbook.Worksheets.Add("Sheet1");
                var sheet2 = package.Workbook.Worksheets.Add("Sheet2");
                sheet1.Cells[2, 2].Formula = "Sheet2!C3";
                sheet2.Cells[3, 3].Value = "Hello, world!";
                package.Workbook.Calculate();
                Assert.AreEqual("Hello, world!", sheet1.Cells[2, 2].Value);
                sheet2.InsertRow(3, 10);
                package.Workbook.Calculate();
                Assert.AreEqual("Hello, world!", sheet2.Cells[13, 3].Value);
                Assert.AreEqual("'Sheet2'!C13", sheet1.Cells[2, 2].Formula, true);
                Assert.AreEqual("Hello, world!", sheet1.Cells[2, 2].Value);
            }
        }
I am working on a fix at the branch here.

comments

emdelaney wrote Apr 26, 2016 at 8:59 PM

Pull request #8800 will resolve this issue.

bibujakera wrote Mar 17 at 6:33 AM

Good day,
I'm having the same issue. I want to know how did you resolve it.

Regards,
Bibujakera