Aspose.Cells for Java - TEXTBEFORE and TEXTAFTER formulas cause exception in Workbook calculateFormula

Hello,

When we call Workbook calculateFormula on a file containing the formulas TEXTBEFORE or TEXTAFTER, we get a CellsException.

com.aspose.cells.CellsException: java.lang.NullPointerException: Cannot read the array length because "<local8>" is null(Based on cell Sheet0!I5)

code that’s being used:

final File filepath = "<PATH>/textbefore-textafter.xlsx"; final Workbook workbook = new Workbook(filepath.getAbsolutePath()); workbook.calculateFormula();

Formulas in Excel file (attached):

=TEXTBEFORE(“Red riding hood’s, hood”, “hood”)
=TEXTAFTER(“Red riding hood’s, red”, “hood”)

Same project as this post - just a different formula causing a similar exception

@jlivena,

Thanks for the details.

We reproduced the issue as you mentioned by using the following sample code. I found TEXTBEFORE and TEXTAFTER formulas cause exception in Workbook.calculateFormula.

Workbook workbook = new Workbook();
Worksheet ws = workbook.getWorksheets().add("Data");
ws.getCells().get("A1").setValue("X match");
ws.getCells().get("B1").setFormula("=TEXTAFTER(A1,\"\")");
ws.getCells().get("B3").setFormula("=TEXTBEFORE(\"Red riding hood's, hood\", \"hood\")");
ws.getCells().get("B4").setFormula("=TEXTAFTER(\"Red riding hood's, hood\", \"hood\")");
workbook.calculateFormula();
String b1Value = (String)ws.getCells().get("B1").getValue();
System.out.println(b1Value.toString());

Exception:

Exception in thread "main" com.aspose.cells.CellsException: java.lang.NullPointerException: Cannot read the array length because "<local8>" is null(Based on cell Data!B1)

We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSJAVA-45961

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you have found earlier (filed as CELLSJAVA-45961) have been fixed in Aspose.Cells for Java 24.5.