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

Free Support Forum - aspose.com

How to get the refers to for a named range in Aspose version 7?

In Aspose version prior to 7 the getNamedRanges returned an array of NamedRange
this class had a method called getRefersTo(). How can we get the range defined by the name in version 7?



Old code pre Aspose ver 7:

NamedRange[] nr = workbook.getWorksheets().get(sheetIndex).getNamedRanges();
for (int i = 0; nr != null && i < nr.length; i++) {
namedRangesMap.put(nr[i].getText(), nr[i].getRefersTo());
}

New code Aspose ver 7:

Range[] nr = workbook.getWorksheets().getNamedRanges();
for (int i = 0; nr != null && i < nr.length; i++) {
namedRangesMap.put(nr[i].getName(), nr[i].getRefersTo()); ???
}

Hi,

Please try this code and see if it fits your need.

Please see the sample input xls file and the output of this code. I have used the latest version:
Aspose.Cells for Java v7.0.3.2


Java


String path = “F:\Shak-Data-RW\Downloads\AposeCellsProblem\Test.xls”;

Workbook workbook = new Workbook(path);

Range rng = workbook.getWorksheets().getRangeByName(“myRange”);

String refersTo = rng.toString();


System.out.println(refersTo);

Output:
Aspose.Cells.Range [ Sheet1!A1:D3 ]

Hi,

I do not think it is safe to parse and extract the information from the toString method.

Then I use it for something that it is not intended to and do not trust that the output from this method will change without notice. What do you think?

Actually the toString is different for 7.0.2.0 and 7.0.3.0

Hi,

OK, and we will provide Range.RefersTo property setter/getter later on.

Hi,

Please try the attached version/fix: v7.0.3.3.

Now we have added a new method: Range.getRefersTo() for your requirement. Please try the new fix.

Thank you.

Thank you, now I can remove my own RangeHelper class

The issues you have found earlier (filed as CELLSJAVA-40054) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.