Concurrent Workbook.CalculateFormula() calls on different Workbook objects throws CellsException

Hi,

I am a software dev at a company evaluating if Aspose.Cells is suitable for its needs.

I am inputting data, executing formulae and reading output data from an Excel file. The Excel file contains circular references, which Aspose.Cells deals with just fine. I cannot provide the Excel file as reference, because it is copyrighted.

In order to deal with simultaneous requests to the Excel file’s content, I need to concurrently access its data. To avoid the usual data corruption issues, the Excel file is read into memory as a byte array and then the byte array is being written to multiple Stream instances. For each thread the Stream instance created during the previous step is passed to the Aspose.Cells.Workbook constructor. As such, I have multiple separate Workbook instances based upon the content of the original Excel file.

The previous setup ensures complete isolation of data and object instances. However, when performing the same processing as before, but in parallel on the multiple Workbook instances, circular reference errors occur:

threw exception: 
System.AggregateException: One or more errors occurred. ---> Aspose.Cells.CellsException: Circular Reference for    [0]

Stack trace:
at . ()
at Aspose.Cells.Workbook.CalculateFormula(CalculationOptions options)
at Aspose.Cells.Workbook.CalculateFormula(Boolean ignoreError, ICustomFunction customFunction)
at Aspose.Cells.Workbook.CalculateFormula()

These errors do not happen when processing the multiple Workbook instances sequentially, which is surprising to say the least, considering there is no shared state between Workbook instances in my application code.

Is there any shared state (static data) in the code of the class Aspose.Cells.Workflow, or, at the least, shared state in some code dealing with circular references? What else could it be that affects separate Workbook instances when used concurrently, but sequentially works without issue?

I am looking forward to hearing from you!

Best regards,
Mihnea

@mihnea,

Thanks for sharing some details.

Well, we need a sample console demo application (runnable), you may zip the project prior attaching. We also need your template Excel file used in your code. If you have reservations in sharing the file in the forums, we request you to kindly replace your original data (in the file) with some dummy data and insert formulas just for the sake to reproduce the issue on our end. This is necessary as we got to reproduce the issue first on our end and then we will figure it out precisely or provide you some other way around to cope with your issue accordingly.

For your information, Aspose.Cells is a pure .NET component created in managed C#, so , concurrency and multithreading should not be a problem by any means. Our several users do use the component in their diverse environments in different types of (desktop, client server etc.) solutions (Winforms, web forms, windows/web service, console app. etc.) or other scenarios without any problem. As long as you don’t have shared data source and every time a user access the application a new Workbook or Excel file is generated, there would be no problem at all. However, if you have a shared data/resource, then you will have to do synchronization by yourself. Also, in that case, we recommend you to create/manipulate of filling data into different workbooks in different threads accordingly, because, you should not use one workbook/file in multiple threads at the same time least you would not get stable data due to restrictions and complexity (involved) put forth by MS Excel for its file format(s).

Thank you.

@mihnea,

Thanks for using Aspose APIs.

We do find one possibility of concurrent issue when calculating formulas with circular references in multiple threads. We will provide a fix to you to test whether it can solve your issue.

This issue has been logged as

  • CELLSNET-45492 - Concurrent issue when calculating formulas with circular references in multiple threads

Hi @shakeel.faiz,

Thank you very much for your quick reply and the promise to provide me with a fix.

The concurrency issue is the determining factor in my company’s decision whether to buy the product.

Can you supply me please with a prospective time frame when the fix will be made available, so that we can update our project execution plan accordingly?

Best regards,
@mihnea

@mihnea,

Thanks for considering Aspose.Cells.

Please spare us a little time (3-5 working days or so). Hopefully, we could figure out the issue and provide you the fix in this time frame.

Keep in touch.

Thank you.

@mihnea,

We have fixed one possible bug which may cause such kind of issue. Please try our new release v17.7.0 to check whether your issue is fixed:

FYI: 17.7 is available for download in the download section.

Download Section:

Direct Link:

Let us know your feedback.

Thank you.

Hi @Amjad_Sahi,

Thank you very much for supporting my effort with this release!

It does indeed fix the concurrency issue for me.

Best regards,
Mihnea

@mihnea,

Thanks for your feedback.

Good to know that your issue is sorted out by the new version/fix, we have closed your ticket now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.