Hi ,
I have attached the tempalte and the error has occured for the following code chain:
import com.aspose.cells.*;import org.junit.Test;import java.util.ArrayList;public class DummyTest {public class CustomFunction implements ICustomFunction{@Overridepublic Object calculateCustomFunction(String functionName, ArrayList paramsList, ArrayList contextObjects) {return 1;}}private void replaceFormula(Workbook wb, String cell, int sheetIndex) {wb.getWorksheets().setActiveSheetIndex(sheetIndex);Cells cells = wb.getWorksheets().get(sheetIndex).getCells();String findString = cells.get(cell).getFormula();FindOptions opt = new FindOptions();opt.setRange(CellArea.createCellArea(0, 0, cells.getMaxRow(), cells.getMaxColumn()));opt.setLookAtType(LookAtType.CONTAINS);opt.setCaseSensitive(false);opt.setSearchNext(true);opt.setLookInType(LookInType.FORMULAS);Cell findCell = cells.find(findString, null, opt);if (findCell != null) {String formula = findCell.getFormula().replace(’,’, ‘;’);findCell.putValue(formula.substring(1), true);}}private void invalidateCell(Cell cell, ICustomFunction resolver) {// The below code line causes NullPointerExceptionCell[] dependents = cell.getDependents(true);if (cell.getFormula() != null) {cell.calculate(true, resolver);}if (dependents != null) {for (Cell dependedCell : dependents) {invalidateCell(dependedCell, resolver);}}}public void testGetDependents() {try {Workbook wb = new Workbook(“D:\in.xlsx”);CustomFunction customFunction = new CustomFunction();replaceFormula(wb, “E1”, 0);replaceFormula(wb, “E1”, 1);// This method throws error, see detailsinvalidateCell(wb.getWorksheets().get(1).getCells().get(“E1”), customFunction);System.out.println(“Success”);} catch (Exception e) {System.out.println(“Error”);e.printStackTrace();}}}
The output look as follows:
Could you scrutinize the issue and fix the problem?Errorjava.lang.NullPointerExceptionat com.aspose.cells.bfr.c(Unknown Source)at com.aspose.cells.ew.a(Unknown Source)at com.aspose.cells.Cells.getDependents(Unknown Source)at com.aspose.cells.Cell.getDependents(Unknown Source)at com.asuproject.DummyTest.invalidateCell(DummyTest.java:41)at com.asuproject.DummyTest.invalidateCell(DummyTest.java:48)at com.asuproject.DummyTest.testGetDependents(DummyTest.java:65)…
We tested both Aspose.Cells 7.x and 8.0.1 versions, this bug is not fixed.
Thanks.