Skip to content

Commit

Permalink
Added fix for #1628. Corrected ids on deleting tables (#1634)
Browse files Browse the repository at this point in the history
modified:   EPPlusTest/Issues/LegacyTests/Issues.cs
  • Loading branch information
OssianEPPlus authored Oct 23, 2024
1 parent 90de83f commit acd83ad
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 1 addition & 2 deletions docs/articles/fixedissues.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@





* Deleting and adding a table with multiple worksheets no longer gives the added table an invalid id.
* Ensured ExcelPictures are sized correctly when copying worksheets
* Fixed issue where adding rows to a Table that contained error values would throw error or generate a corrupt workbook. When the table was the source range of a pivot table.
* Fixed ExcelErrorValues GetHashCode and Equals methods to return appropriate Type value.
Expand Down
1 change: 0 additions & 1 deletion src/EPPlus/Table/ExcelTableCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public void Delete(ExcelTable Table, bool ClearRange = false)
{
if (t.Id > Table.Id) t.Id--;
}
Table.WorkSheet.Workbook._nextTableID--;
}
foreach(var name in _tableNames.Keys.ToArray())
{
Expand Down
1 change: 1 addition & 0 deletions src/EPPlusTest/Issues/LegacyTests/Issues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Date Author Change
*******************************************************************************
01/27/2020 EPPlus Software AB Initial release EPPlus 5
*******************************************************************************/
using EPPlusTest.Table;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using OfficeOpenXml;
Expand Down
22 changes: 22 additions & 0 deletions src/EPPlusTest/Table/TableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,5 +1044,27 @@ public void ThrowsWhenAttemptingToAddSameName()
table.Columns[1].Name = "AColumn";
}
}

[TestMethod]
public void DeleteAndAddTableTest()
{
using (var package = OpenPackage("tableTestpck.xlsx", true))
{
var ws = package.Workbook.Worksheets.Add("WsCheck");

var table = ws.Tables.Add(ws.Cells["A1:C10"], "ATable");

var ws2 = package.Workbook.Worksheets.Add("WsCheck2");
var ws3 = package.Workbook.Worksheets.Add("WsCheck3");

ws.Tables.Delete(table);

var table2 = ws.Tables.Add(ws.Cells["A1:C10"], "ATable");

Assert.IsTrue(table2.Id > 0);

SaveAndCleanup(package);
}
}
}
}

0 comments on commit acd83ad

Please sign in to comment.