Range Name Issue NPE and Suggestions

Currently we have using version 7.1.2 of aspose, there is an situations where we extend the range in our application. This is done by checking if the name exists in the names, if it does then we simply do Worksheets.getNames().remove(“RANGE_NAME”) and then create new range. This works fine almost every time, but in few scenarios we end up with NullPointerException when we say Worksheets.getNames().remove(“RANGE_NAME”), we tried to replicate the issue standalone, so that we can post-in here but I am not able to come up with the use-case which is causing this problem to happen. We will be posting the problem if we know how we end up with NPE during remove.
We create Range by Worksheet.getCells().createRange(startRow, startCol, height, width), which gives us Range Object, for our needs we need to move and change startRow, startCol, height and width of the Range. Range object has one method moveTo(int, int), which will address one of our startRow and startCol issue, but Range does not provide to set height and width (atleast I can’t see it).
Could you please suggestion how to go about it, are there any other ways to accomplish this. If I am not clear on what we are trying to achieve, please find the below example which can be clear.

example:
1. Need to create a range with name “TestRange1”, row and column as 1 and 5 with height and width as 1.
2. Lets say “TestRange1” has been created, now wanted to extend the range cells to include more columns in it. lets take row and column as 1 and 5, height and width as 2, 3.

Hi,


Well to reproduce the issue (i.e. NPE) and to evaluate your issue, we surely need your sample project with your template file. So, kindly create a sample runnable JAVA program and post us here with the files, we will check it soon.

For your needs, I think you may try to use Name/NameCollection APIs, e.g

//Get the named range
Name name = workbook.getWorksheets().getName(“TestRange1”);
//set your desired range’s criteria in string
name.setRefersTo("_______");

Thank you.

Hi,
The suggested setRefersTo("") works like a charm, thanks for the quick help.
Regarding the NPE issue, we are still seeing this problem in our application but not able to reproduce it on standalone (we are not able to come up with the exact use-case which is causing the problem), will definitely post if we get the exact use-case.

thanks and regards,
Mahesh Pujari

Hi,

It’s good to know than your issue is resolved.

For your NPE issue, please download and use the latest version:
Aspose.Cells
for Java v7.2.0.2

and let us know your feedback.