Combining sheets from different workbooks results in corrupt file that can crash Excel

When building a single Excel reporting package using Aspose.Cells based on multiple copies of worksheets from multiple source Excel files, it appears that you can end up with a workbook that can crash Excel (window just disappears). Have seen this in a recent version of Excel: Version 2205 (Build 15225.20288).

The attached sample Visual C# console application and files should help demonstrate/simulate this problem which I have seen in testing with several 22.x Aspose.Cells versions (most recently 22.6.1), but not in older Aspose.Cells versions like 21.7.6. If you put a 22.x release of Aspose.Cells.dll in the Content folder you should be able to run the application. (99.5 KB)

The sample application begins with a Cover Page.xlsx workbook as a starting point. A copy of its only worksheet is made and then renamed, removing the original. The worksheet in Report Template.xlsm is then copied multiple times into the main workbook, and this workbook is then saved with a different name (“Report Package.xlsx”). The generated output file should get created in: \bin\Debug\net6.0\Content

If you run this sample application and open the generated “Report Package.xlsx” Excel workbook output in Excel, as you click around the different tabs in the workbook (for instance, clicking back to select the “a” tab) Excel will almost always crash or close the instance of Excel with that file. Excel may generate a repaired copy the generated Excel file the next time you open Excel.

The interesting thing is that if the number of copies of the sheet in the “Report Template” workbook in this example is reduced to fewer than 7 the generated Excel file does not appear to crash/close Excel. But generate 7 or more copies and the file is likely to crash Excel as you click around the various tabs.

One last note is that it seems like the generated workbook may also have incorrect merged styles from both workbooks-- perhaps that is a consequence of Excel’s automatic repair operations on the generated file when Excel crashes, but I wanted to mention it in case it is related.


Thanks for the template files and sample.

I did test your scenario/case using your sample project after updating the line of code to:
int numberOfCopies = 8;
and generated the output file named “Report Package1.xlsx” (attached). I navigated in different sheets after opening it into MS Excel but could not notice MS Excel to crash. Do I need to wait for some time to get MS Excel crashed? Could you check and open the file into your MS Excel and share if you see corrupted file and Excel crashing issue? If so, kindly do share what is MS Excel version details. Also, give your output file generated on your end after processing your sample code. We will check your issue soon.
Report (165.2 KB)


I don’t know what changed, but for some reason I can no longer reproduce this locally.

However, one of my colleagues can reproduce the problem using your file by clicking on sheets in this order: 11, 10, 9, 8, 7, 6, 1, 2 (the file closes unexpectedly, but Excel remains open). The same colleague can also reproduce the reported issue with the sample code as-is, which generated the attached workbook (clicking sheets in this order: 9, 8, 7, 6, 5, 4, 1, 2 - Excel closes unexpectedly). (143.7 KB)

Both of us are running identical Excel 16.15225.20288 and Aspose.Cells 22.6.1 versions. I am not sure why only one of us sees the problem, but if there’s more information we can provide for you please let me know!



Thanks for providing further details.

I am now able to reproduce the issue as you mentioned by using your sample with your template file. Earlier, I did test your scenario/case using your sample project after updating the line of code to:
int numberOfCopies = 8;
and generated the output file. I now opened the file into MS Excel 2016 and navigated to different sheets (in sequence: 9, 8, 7, 6, 5, 4, 1, 2) and MS Excel crashes/closes unexpectedly. I have logged a ticket with an id “CELLSNET-51482” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

1 Like

Thanks so much-- I appreciate it!


You are welcome.


This is to inform you that your issue has been resolved now. The fix will be included in the next release (Aspose.Cells for .NET v22.7) which is scheduled in the second week of July 2022. You will also be notified when the next version is released.

The issues you have found earlier (filed as CELLSNET-51482) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi