Free Support Forum -

Loading existing named ranges

If I read the documentation correctly, calling Cells.getRanges() returns only the named ranges created through the Aspose API.

Couple of questions here:

  • I’d like to be able to load the set of pre-existing ranges and then update one. Is that possible?
  • Failing that, if I define a range that already exists, what is the result?
- David


You can access the named ranges created manually using Ms-Excel using the following method.


As a workaround to update your existing range, you should create a new range and delete the old one.

Thanks for that info. However, I am not finding that to work with

My code is:
Workbook book = new Workbook(“sample.xlsx”);
WorksheetCollection sheets = book.getWorksheets();
Range[] ranges = sheets.getNamedRanges();

I get null back, even though I have 5 named ranges in my xlsx file.


Please attach your template Sample.xlsx file here, we will check your issue soon.

Thank you.

Please see attached. It’s actually called “SmallData.xlsx”.


Thanks for your template file.

Your named ranges in your template file are defined Names (NameCollection), you should use the following sample code for your requirement:

Sample code:
Workbook book = new Workbook(“SmallData.xlsx”);
WorksheetCollection sheets = book.getWorksheets();
NameCollection ranges = sheets.getNames();
System.out.println(ranges.getCount()); //5 -OK

for(int i =0; i<ranges.getCount(); i++)


Thank you.