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
You can currently delete worksheets while iterating through the same worksheets. This causes issues as the worksheet originally at index [1] gets locked to index 0.
Per standard iteration of e.g. List we should throw if the collection is changed while iterating through it.
We should also add a RemoveAll() function to Worksheets with a predicate similar to List
[TestMethod]publicvoidDeletingWorksheetsWithParameters(){using(varp=OpenPackage("DeletingGroupOfWorksheets.xlsx")){varwb=p.Workbook;varworksheets=wb.Worksheets;for(inti=0;i<5;i++){worksheets.Add($"Data {i}");}for(inti=0;i<5;i++){worksheets.Add($"SomeWorksheet{i}");}//Deleting worksheets with foreach//Skips over index[1]//Should probably throw as the enumerator changes while in itforeach(varwsinp.Workbook.Worksheets){if(ws.Name.StartsWith("Data ",StringComparison.OrdinalIgnoreCase)){p.Workbook.Worksheets.Delete(ws);}}varcountWs=p.Workbook.Worksheets.Count();Assert.AreEqual(countWs,5);}
Worksheets.Delete() on RemoveAndShift appears to cause the skipping.
Ideally users should be able to do something like Remove all or Delete all :
You can currently delete worksheets while iterating through the same worksheets. This causes issues as the worksheet originally at index [1] gets locked to index 0.
Per standard iteration of e.g. List we should throw if the collection is changed while iterating through it.
We should also add a RemoveAll() function to Worksheets with a predicate similar to List
Worksheets.Delete() on RemoveAndShift appears to cause the skipping.
Ideally users should be able to do something like Remove all or Delete all :
The text was updated successfully, but these errors were encountered: