I’ve got InvalidOperationException: “Collection was modified; enumeration operation may not execute.” when tried to remove names for the attached workbook.
Here is code which you can use to test:
NameCollection names = workbook.Worksheets.Names;
int i = names.Count - 1;
while (i >= 0)
Is it correct to use the next workaround:
1) Save in separate collection those names which I want to keep alive
2) Call workbook.Worksheets.Names.Clear()
3) Add saved in step #1 names to cleared collection
Can this workaround break some internal relationships, or it is safe?
Please download and try: Aspose.Cells for .NET v184.108.40.206
I have tested your scenario using the following code with your template file and it works fine. I can successfully generate the output file having null named ranges in it, all the named ranges are deleted fine.
Thank you for the reply.
Forgot to mention - I used v. 220.127.116.11.
I’ve checked v. 18.104.22.168 - it works correctly.