Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.
Fri Apr 13, 2018 9:12 am
Hi team,
Are there any ways to neatly clear all named ranged defined in INameRanges enumerator?
We found that in INameRanges, it contains Remove(string name) and RemoveAt(int index) to remove the named range one by one.
But we would like to remove all named range at once. And seems it's not an appropriate approach to iterate the ranges and remove then inside the iteration.
Thanks!
-
sxlsgs
-
- Posts: 7
- Joined: Fri Apr 13, 2018 2:06 am
Fri Apr 13, 2018 10:25 am
Hello,
Thanks for your contact.
Sorry there is no way to remove all named range at once, you could use the RemoveAt to remove the named range in turn, sample code is given as below:
- Code: Select all
for (int i = workBook.NameRanges.Count-1; i >=0; i--)
{
workBook.NameRanges.RemoveAt(i);
}
Sincerely,
Nina
E-iceblue support team
-
Nina.Tang
-
- Posts: 1187
- Joined: Tue Sep 27, 2016 1:06 am
Fri Apr 13, 2018 10:30 am
Noted, thank you!
-
sxlsgs
-
- Posts: 7
- Joined: Fri Apr 13, 2018 2:06 am