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

Free Support Forum - aspose.com

Object reference error when opening Xlsx on multi threads

I am evaluating Aspose.Cells for our project need.
I have a simple application to open workbook, set few cells, and calculate a formula and read the value.

So i am using code like
var workbook = workbook.Open(“my.xlsx”)

When I run this code with Single thread 50 times, it works fine.
When i the code on multiple threads, it throws error on Workbook.Open method on different cells each time, saying

Object reference not set to an instance on Cell [D2]

each time, its different cell. Does Aspose.Cell work in multiple threading environment?

And is there any way to cache Opened workbook / sheet, and use as separate copy on thread? so calculation of formula works fine on all threads concurrently?



Well, Aspose.Cells for .NET is a pure .NET component that is written in managed C#. So, there is not problem with the component using it concurrently in multi-threads. Bur, for your info, to save memory, there is a global shared string table in an Excel file. So if you change a single workbook data by opening it concurrently in multi-threads, the result might be unstable. There is also a global section in an Excel file which contains global information of drawing objects and other information etc. So, if you want to change the objects settings concurrently in multi-threads, the result might be unstable too. It is to be noted here, this is the limitation of MS Excel formats and nothing to do with Aspose.Cells for .NET component. So, the best way to utilize multi-threading is to create separate Workbook objects in each thread. Your application can handle multi-workbooks at the same time but please don’t handle a single Excel file in multi-threads.

Thank you.

Thanks for the reply Amjad.

I am opening new workbook object on each thread separately by calling Workbook.Open. But since its same excel file that am trying to open, it throws this error randomly on few threads.

I am not using any global information. Since I am creating new workbook on each thread, it should not throw any error. But for some reason, I think Aspose cells keeps shared memory across threads.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please create a sample project, zip it and post it here with template files to reproduce the issue. We will check it soon.

Thank You & Best Regards,

I have attached sample windows application. It is failing on random places when running with multi threading.

thank you.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

We have found your mentioned issue after an initial test. We will look into it and get back to you soon. Your issue has been registered in our internal issue tracking system with issue id CELLSNET-14272.

Thank you & Best Regards,

Hi, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please try the attached latest version of Aspose.Cells for .NET. We have fixed your mentioned issue regarding multi threading.

Thank You & Best Regards,