We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Range.Name does not return name of an existing named range


Say I have created a range object (e.g. a1:a2) and have set its name to something (e.g. "test"). Now if I create another range object with the same addresses, its name property is empty. See below code for example:


var worksheet = new Workbook().Worksheets[0];

var range = worksheet.Cells.CreateRange("a2", "a2");
var rangeName = "test";

range.Name = rangeName;

var range2 = worksheet.Cells.CreateRange("a2", "a2");

// ****** Shouldn't range2 have a .Name value of "test" instead? ******
Assert.That(string.IsNullOrEmpty(range2.Name), Is.True);


Is this intended behavior? If so, how can I get the name of an existing range given any arbitrary range?



Hi Steve,

Well, I think the behavior is fine. In MS Excel(2003), you can add more than one named ranges for a single location and you do require to provide the name for each Named Range. If you do not provide the name for the named range, it will be null. I think for your need, you may get the existing named range in the way:

var range2 = worksheet.Workbook.Worksheets.GetRangeByName(rangeName);

Thank you.