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

Free Support Forum - aspose.com

Range is Nothing


i try to get named ranges from attached Excel-file.

First range is called ‘BIP_range_simple’.
The area includes B1 to C4.
When i use 'GetRangeByName(“BIP_range_simple”) i get a proper range.

Second is called ‘BIP_range_komplex’.
the area includes A1 to A11 plus C1 to C11.
When i use 'GetRangeByName(“BIP_range_komplex”) the range is nothing.

I use Aspose.Cells Version


Thanks for providing us the template file.

Since “BIP_range_komplex” is defined Name having non sequenced ranges in it, so, you will not use Range object directly. Please use Name API to get the defined Name first. If you want to get the ranges for “BIP_range_komplex”, you can use Name.GetRanges() to obtain an array of ranges ([]Range) in the defined Name. I have created a sample code for your reference, kindly refer to it, it works fine as I tested.

Sample code:

Workbook wb = new Workbook();

Name name = wb.Worksheets.Names[“BIP_range_komplex”];
MessageBox.Show(name.RefersTo); //fine

Range[] ranges = name.GetRanges();

int frow, fcol;
int rowcount, colcount;

if (ranges != null)
for (int i = 0; i < ranges.Length; i++)
frow = ranges[i].FirstRow;
fcol = ranges[i].FirstColumn;
string f1 = CellsHelper.CellIndexToName(frow, fcol);
MessageBox.Show(ranges[i].FirstRow + “:” + ranges[i].FirstColumn);

rowcount = ranges[i].RowCount - 1 + ranges[i].FirstRow;
colcount = ranges[i].ColumnCount - 1 + ranges[i].FirstColumn;
string f2 = CellsHelper.CellIndexToName(rowcount, colcount);

MessageBox.Show(f1 + “:” + f2);


Thank you.