You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Table DeleteRow deletes whole worksheet rows (and breaks named ranges) when the table starts in column A and is past row 16384 #2591
(This happens in 8.7.2, and the code looks the same in 9.0 preview.)
If a table starts in column A and you delete rows from it that end at row 16384 or further down, EPPlus deletes the entire worksheet rows instead of just the table's rows. We noticed two things go wrong:
anything to the right of the table on those rows is deleted, and anything to the right below them moves up
a workbook-level name that points at a table column, like Table1[Flag], gets saved as a plain range with no sheet name, e.g. $B$5:$B$16387. Excel then says the file has a problem, repairs it and drops the name ("Removed Records: Named range from /xl/workbook.xml part").
If the table starts in column B instead, or the deleted rows end at row 16383, it works fine.
I think it comes from this line in ExcelRangeBase.Delete(eShiftTypeDelete shift):
_toRow is compared with MaxColumns (16384). Should that be _toCol?
The name part seems to follow from that: the whole-row path calls ExcelNamedRangeCollection.Delete with 0 as the column limits, so the name's Address is replaced with the shifted range. _table is still set on the name though, and SetNameElement writes Address rather than FullAddress when Table != null, so the sheet name is lost on save.
Steps to reproduce:
Make a sheet with a table at A4:B16390 and a workbook-level name FlagColumn = Table1[Flag].
Save and reopen the package, so the name is read from the file the way it would be from a workbook made in Excel.
Delete the last 3 rows of the table with DeleteRow(16383, 3).
Save and look at xl/workbook.xml, and at D16389.
usingvarpackage=newExcelPackage();varsheet=package.Workbook.Worksheets.Add("Sheet1");sheet.Cells["A4"].Value="Item";sheet.Cells["B4"].Value="Flag";for(varrow=5;row<=16390;row++){sheet.Cells[row,1].Value="Item "+row;sheet.Cells[row,2].Value="Y";}sheet.Cells["D16389"].Value="next to the table";sheet.Tables.Add(sheet.Cells["A4:B16390"],"Table1");package.Workbook.Names.AddFormula("FlagColumn","Table1[Flag]");// save and reopen so the name is loaded from the fileusingvarreopened=newExcelPackage(newMemoryStream(package.GetAsByteArray()));vartable=reopened.Workbook.Worksheets["Sheet1"].Tables["Table1"];table.DeleteRow(16383,3);// the last 3 rows, 16388-16390File.WriteAllBytes("out.xlsx",reopened.GetAsByteArray());
Expected: <definedName name="FlagColumn">Table1[Flag]</definedName>, and D16389 still says "next to the table".
What we get: <definedName name="FlagColumn">$B$5:$B$16387</definedName>, and D16389 is empty.
Activity
JanKallman commentedon Oct 21, 2026
Thanks for the detailed description of this issue.
This is a bug. I will provide a fix shortly.
JanKallman commentedon Oct 21, 2026
This is a bug. I will provide a fix shortly.
JanKallman commentedon Oct 21, 2026
I have added a fix for this issue. Please see linked PR.
Fixes issue EPPlusSoftware#2591