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

Free Support Forum - aspose.com

Worksheet.calculateFormula throws and NPE. Aspose.Cells 8.6.2.1

Hello,

I am building an Excel formula evaluation framework, and being able to calculate user formulas against specific worksheets is crucial for this purpose. Worksheet.calcualteFormuala(String formula) method, however, blows up with NPE. I am using NameCollection to define workbook variables that will later be used in formulas. Here is the code snippet:

Workbook book;
String isP10OrP90 = “=ISNUMBER(FIND(“P10”,$B$7))”;
try (InputStream stream = getFileAsStream(“Armada.xlsx”)) {
book = new Workbook(stream);
Worksheet sheet = book.getWorksheets().get(3);

// Define a variable that will hold the result of isP10OrP90 formula
NameCollection names = book.getWorksheets().getNames();
names.add(“isP”);
Name isP = names.get(“isP”);
isP.setRefersTo(isP10OrP90);

// Referencing the variable from a cell works fine
Cell cell = sheet.getCells().get(“A5”);
cell.setFormula("=isP");
book.calculateFormula();

// Referring to cells or constants in the worksheet works fine:
Object two = sheet.calculateFormula("=CONCATENATE(A1, A2)");

// The following call, referring a variable, blows up.
Object one = sheet.calculateFormula("=isP");
System.out.println(one);
}

Have I forgotten to call some “evaluate” method? Is this workflow supported?

Thanks

Hi,

Thanks for your posting and using Aspose.Cells.

Please also provide us source excel file (i.e Armada.xlsx) used in your code so that we could execute it at our end and investigate it.

Please also download and try the latest version: Aspose.Cells for Java v8.7.2.1 to see if it makes any difference and resolves your issue.

Thanks for the prompt response.
The issue is present with any Excel file I tried it with. Here is one, for example.
And updating to the latest version made no difference.

Hi,

Thanks for your clarification and using Aspose.Cells.

We were able to replicate this issue by executing your sample code with your source excel file using the latest version:
Aspose.Cells for Java v8.7.2.1 and found that Worksheet.calculateFormula throws null pointer exception when formula is set via NameCollection.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

  • CELLSJAVA-41809 - Worksheet.calculateFormula throws null pointer exception when formula is set via NameCollection

How do I know if/when the issue is fixed?

Hi,

Thanks for your posting and using Aspose.Cells.

Once the issue ticket will be marked as resolved, we will notify you by posting in this thread. And then after few more days, we will provide you a fix in this thread too.

Please note, the fix will be a minor version and not the official version. Official version will be released around 20-25 April 2016. Once the official version will be available for you, you will get automatic notification from Aspose.

Hi,

Thanks for using Aspose.Cells.

This is to inform you that we have fixed your issue CELLSJAVA-41809 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for Java v8.7.2.5 and let us know your feedback.

Seems to work!

Thanks!

Hi,


Good to know that your issue is sorted out by the new fix/version. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.

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


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan