wbook.Worksheets.GetRangeByName(“RANGE”) returns null if “RANGE” is not rectangle area. For example, try to name range that consists of cells A1 and A3. It’s very strange because non-rectangular ranges in Excel are allowed and work fine.
Hi Vladimir,
Please forward us your sample application and excel file. This will help us finding the issue.
Thanks,
Please, here you are.
Hi,
If you are implementing/retrieving non rectangular ranges, please see the following sample code for reference:
Workbook workbook = new Workbook();
workbook.Open(@“e:\test\nonrec\AsposeExcelRange\named_range_bug.xls”);
Name name = workbook.Worksheets.Names[“BUG_RANGE_2”];
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.
Thank you for this workaround. At this moment it’s enough for me.