Free Support Forum - aspose.com

Workbook.calculateFormula() results in stack overflow

We’re using Aspose.Cells for Java V1.9.4.

Our Excel spreadsheet opens fine in Excel and seems to work fine in Aspose.Cells until we call a recalc. Then, it hangs for a very long time, until a stack overflow occurs.

I’ve attached the spreadsheet.

Here is my testing code:

import java.io.IOException;
import com.aspose.cells.Cell;
import com.aspose.cells.Workbook;

public class AsposeTest {


public static void main(String[] args) {


Workbook simWorkbook = new Workbook();
try {
simWorkbook.open("/Users/brandon/Documents/sim.xls");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

Cell simCell = simWorkbook.getWorksheets().getSheet(“Output”).getCells().getCell(“G625”);
System.out.println("Cell value: " + simCell.getStringValue()); // Outputs the correct value
simWorkbook.calculateFormula(); // hangs here until stack overflow
System.out.println("Cell value after recalc: " + simCell.getStringValue()); // Never reaches this statement!
}

Here is a small portion of the error, by the way.

Exception in thread “main” java.lang.StackOverflowError
at com.aspose.cells.aE.e(Unknown Source)
at com.aspose.cells.dr.a(Unknown Source)
at com.aspose.cells.w.a(Unknown Source)
at com.aspose.cells.Cell.b(Unknown Source)
at com.aspose.cells.Cell.c(Unknown Source)
at com.aspose.cells.bl.a(Unknown Source)
at com.aspose.cells.bl.g(Unknown Source)
at com.aspose.cells.Cell.a(Unknown Source)
at com.aspose.cells.Cell.b(Unknown Source)
at com.aspose.cells.Cell.c(Unknown Source)
at com.aspose.cells.bl.a(Unknown Source)
at com.aspose.cells.bl.g(Unknown Source)

Hi,

Thank you for your template file, we have found the issue and will figure it out soon.

Thank you so much for the quick response!!

If the error can be fixed by changing or removing something from the spreadsheet, can you let us know what it is so that we can continue testing the rest of our application?

Hi,

The fix will be available here soon. Just keep an eye on this thread for it.

Thank you.

Hi,

Thank you for your patience, we have found this issue is caused by too many recursive reference of formula, such as the formula of cell LO2!K6, please try this attached fix to continue the rest work of your application.

This fix just catches the error for those formulas and ignore it, so, the result of those formula will be invalid.

We are still researching into it to check whether we can optimize some for calculating such formula. If we can, we will update the fix for you as soon as possible.

Thank you.

Hi,

Please try this attached fix, we have optimized some for calculating shared formula and it works fine with your template file now. Thank you.