EPPlusSoftware/EPPlus

Why can parallel modification of row height and column width be done on Windows, but not on Linux

Opened this issue · 2 comments

EPPlus usage

Personal use

Environment

linux

Epplus version

7.2.2

Spreadsheet application

excel

Description

I am a student engaged in a restaurant management system teaching project. I have learned that EPPlus is excellent .NET project, so I am currently trying EPPlus 7.2.2. However, it is not suitable for cross platform operation. Windows can run normally and perform well, while Linux throws exceptions. I found the exception code because I parallelly modified the row height, column width, and image size in asynchronous concurrency. Therefore, I tried to read some source code and found that in the ExcelDrawings class, d_drawingsList=new List<ExcelDrawing(); This is not a concurrent collection, but why can Windows do it?

The exception :

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.Collections.Generic.List`1.Enumerator.MoveNext()
   at OfficeOpenXml.Drawing.ExcelDrawings.GetDrawingHeight()
   at OfficeOpenXml.ExcelRow.set_Height(Double value)

Could you attach an example project with some code and a workbook that replicates this issue?

Just to add a comment on this topic: we don't recommend to have multiple threads manipulating a single workbook. While this might work in some cases (as it obviously does in your case on Windows) you are likely to sooner or later run into unexpected issues or errors. We will have a look at improving this in future versions, but for now my advice would be to not do parallell work on a workbook.