We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cancel long-running calculation

Some workbooks for which we recalculate formulas using Aspose Cells can take a long time to fully recalculate.

Sometimes we need to cancel an existing calculation - for example, new data becomes available that makes the running calculation obsolete.

How can we cancel an existing (concurrent) call to workbook.calculateFormula()?


Please use the Workbook.InterruptMonitor property. After setting this property, you will be able to interrupt workbook processing in any thread of your choice.


 //To interrupt workbook processing
InterruptMonitor im = new InterruptMonitor();

void Function1()
	//Do your processing in this function or thread
	Workbook wb = new Workbook();

void Function2()
	//Interrupt workbook processing in some other function or thread

Hi Shakeel,

Thanks for the explanation.

Small remark: while opening “InterruptMonitor” in IntelliJ, it showed the decompiled code for it.
The boolean member field does not seem to be volatile, while makes setting it from the interrupting thread, and reading it from the calculating thread (I assume the Aspose calculation engine checks it periodically during calculation) unreliable.
Either the field should be marked volatile, or some other concurrency construct (like AtomicBoolean) should be used to “safely publish” the value across threads.


Currently we do not check the InterruptMonitor when calculating formulas. So it will take no effect for you. We have created one ticket for this requirement and we will try to support it. Also, we will provide option for user to interrupt the calculation in AbstractCalculationMonitor instead of using InterruptMonitor.

Besides, we appreciate you that you have mentioned the possible issue of “volatile” key for InterruptMonitor. We will investigate it and try to make the enhancement.

We will try to provide fix for you in this week or next week.

This issue has been logged as

  • CELLSJAVA-42423 - Cancel long-running calculation of Workbook.calculateFormula method


We have implemented the feature of canceling long running calculation which will be available in the upcoming fix. Once, it is available for you, we will let you know asap.

Here is the sample code in Java for your reference that you will use with the new fix.


MyCalculationMonitor m = new MyCalculationMonitor();

CalculationOptions copts = new CalculationOptions();



class MyCalculationMonitor extends AbstractCalculationMonitor
    public void beforeCalculate(int sheetIndex, int rowIndex, int colIndex)
        if (colIndex==1) //condition to terminate the calculation progress

            interrupt("Interrupted by user!"); //string parameter denotes the exception message when the calculation being terminated. If the parameter is null, then terminate the calculation progress quietly



Please download and try the latest fix and let us know your feedback.

The issues you have found earlier (filed as CELLSJAVA-42423) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.