I created an excel document in c# using the open xml 2.5 sdk. The file opens in excel and works fine till I select print. At this point, excel crashes with the error "Excel has stopped working". I am using Excel 2016. If I save the file first, before selecting print, the problem is fixed.
I was able to find the solution, but couldn't find this question on stackoverflow, so I'm posting and answering my own question. If anyone has any comments for improvement or a better solution, please let me know.
Thanks.