cell.getDependents() ArrayIndexOutOfBoundsException

The operation getDependents() is throwing an ArrayIndexOutOfBoundsException when running cell.getDependents() on a cell with a formula.

    LoadOptions loadOptions = new LoadOptions();
    loadOptions.setParsingFormulaOnOpen(false);

    Workbook workbook = new Workbook(WORKBOOK_PATH, loadOptions);

    Worksheet ws = workbook.getWorksheets().get(0);
    Cell cell = ws.getCells().get("F41");

    // 20.2+

// workbook.parseFormulas(true);

    final Cell[] dependents = cell.getDependents(true); // This throws an exception
    System.out.println("Dependant cells qty:" + dependents.length);

The file presenting this issue is attached to this post.

aspose-19.9-formula-getdependents.zip (20.9 KB)

@PeteLee,

This is not an issue with Aspose.Cells for Java API. The reason for the issue is due to your line of code:
loadOptions.setParsingFormulaOnOpen(false);
Please note, when you set ParsingFormulaOnOpen Boolean attribute to false, it will not extract formulas from the spreadsheet. Thus no formula will be imported/loaded.

To cope with your issue, either specify the ParsingFormulaOnOpen attribute to "true’ or do not set this property.

Alternatively, you may uncomment the following line (if you do not specify ParsingFormulaOnOpen to “false” while loading the workbook):
// workbook.parseFormulas(true);

Let us know if you still have any issue or confusion.

@PeteLee,

Reference relationships(cell’s Dependents, Precedents, .etc.) in the formula cannot be detected unless they are parsed. So if you need to get dependents for a cell, all formulas in the workbook should be parsed.
However, for your situation, we think returning null for this method will be better than throwing ArrayIndexOutOfBoundsException. So we have created one ticket for it and in later versions/fixes we will make this method return null when the cell’s formula has not been parsed.

@PeteLee,
We have enhanced the implementation of Cell.getDependents() now. We will parse those formulas firstly if there are formulas have not been parsed yet before detecting dependents. Please try our latest fix:
aspose-cells-21.12.4-java.zip (7.5 MB)

The issues you have found earlier (filed as CELLSJAVA-44126) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi