After loading a template off the disk, is there any way to loop through the pre-existing named ranges in the worksheet and alter them? Specifically I’m talking about dynamically named ranges (like the ones entered via the Name Manager in Excel, not just ranges with name against them).
Hi,
Thanks for using Aspose.Cells.
Please download and use the latest version:
Aspose.Cells
for .NET v7.3.2.1
Please use the workbook.Worksheets.Names property for your needs.
Please see the following code and its output. I have also attached the source file used in this code.
C#
string filePath = @“F:\Shak-Data-RW\Downloads\source.xlsx”;
Workbook workbook = new Workbook(filePath);
Worksheet worksheet = workbook.Worksheets[0];
NameCollection names = workbook.Worksheets.Names;
foreach (Name name in workbook.Worksheets.Names)
{
Debug.WriteLine("Name: " + name.Text);
Debug.WriteLine("RefersTo: " + name.RefersTo);
}
Output:
Name: TestRange
RefersTo: =Sheet1!$C$2:$G$13
Screenshot: