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

Free Support Forum - aspose.com

Get range by name returns null

hi,

We have an Excel template with attached named range, if using below code to get range by name, it always returns null.

wb.getWorksheets().getRangeByName(“tablebody”).



We don’t want to delete any named range in the template. Any method we can get the range? by scope?



Thanks in advanced.

Hi Sissi,

Thanks for your posting and using Aspose.Cells.

Your code is correct. Please download and use the latest version: Aspose.Cells for Java (Latest Version) it should fix your issue and return you the range successfully.

If your issue still occurs, then please provide us your source Excel file containing your ranges and the sample code replicating this issue for our reference. We will look into it and help you asap.

In case, it is a bug, we will log it in our database so that this issue could be fixed in our future versions.

I already used 8.2.0.4.



Attached my template.

Hi,


Thanks for the template file.

I have evaluated your scenario/ case a bit using your template file. Well, since the valid named range i.e. “tablebody” is defined on worksheet scoped level, so you got to get the named range with reference to its worksheet, see the sample code below that works fine.
e.g
Sample code:

Workbook book = new Workbook(“named+range+template.xlsx”);
Range r1 = book.getWorksheets().getRangeByName(“FormatSheet!tablebody”);
System.out.println("Range name " + r1.toString());


Thank you.