Free Support Forum -

Very long Formula throws StackOverflow exception

Hi. I have found, that library permits to put very long formula (more than permits Excel) to cell, but could not calculate it. You can check following example.

Is it possible to fix this “StackOverflow Exception” ?

Best regards. Alexey

    public void veryLongFormula() throws BookAdapterException {
        Workbook workbook = new Workbook();
        Cells cells = workbook.getWorksheets().get(0).getCells();
        StringBuilder formula = new StringBuilder();
        for (int i = 0; i < 5000; i++) {
            if (formula.length() > 0) {
            formula.append("C").append(i + 1);
            cells.get("C" + (i + 1)).setValue(i);



Thanks for using Aspose APIs.

We are afraid, this is not possible with Microsoft Excel. Please see the following screenshot. It says, you cannot enter more than 8192 characters in Excel formula.


sc.png (50.5 KB)

Hi Shakeel Faiz.

I got it. And i have known, that Excel not able to set so much large formula. But Aspose does’t said something "like to ImproperlyUsingException (IllegalArgumentsException). Also Aspose is able to set (and calculate formulas, that larger than 8192 characters), but at some moment it begins to throw “StackOverflowException”. Is it possible to proccess like this formula and throw something likes “Wrong formula” ?

Best regards, Alexey


Thanks for your posting and using Aspose APIs.

We were able to observe this issue and logged it in our database for further investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will update you asap.

This issue has been logged as

  • CELLSJAVA-42572 - Formula should not contain more than 8192 characters


We have added the constraint for setting formula, if given formula string is longer than 8192, a CellsException will be thrown.

We will soon provide the fix after performing QA and including other enhancements and fixes.

The issues you have found earlier (filed as CELLSJAVA-42572) have been fixed in this update. This message was posted using BugNotificationTool from <a href=“https://#{request.env[“HTTPS_HOST”]}”>Downloads module by Amjad_Sahi

The issues you have found earlier (filed as CELLSJAVA-42572) have been fixed in Aspose.Cells for Java 18.4. Please also see the document for your reference: