First of all, i think the problem is in excel reading the file, but i have to detail a little.
I use this great library to open xlsx file from asp.net, add data and stream the file to the client with no update on disk; works like a charm except...
In some cases i have to hide a sheet depending on user selection and i used package.Workbook.Worksheets[1].Hidden = eWorkSheetHidden.Hidden or VeryHidden.
If i send the file with a sheet Hidden and open it, Excel show it but as i print preview the application crashes.
If instead of print preview i save the file to desktop, close excel and re-open it again and print preview, 90% cases no error.
Luckily (for me) i can delete the sheet instead of hiding, so i bypass the problem; however i wanted to detail it.
thanks,
Fabrizio
Comments: I compared XML code saved from EPPlus to Excel and found that <workbookView ...> in workbook.xml is missing firstSheet="1" activeTab="1". When we hide anything but the first worksheet, Excel figures it out. But if we hide the first one - it doesn't understand. I added this into the saved EPPlus file manually and it fixed the bug. I'll leave code implementation to the other developers.
I use this great library to open xlsx file from asp.net, add data and stream the file to the client with no update on disk; works like a charm except...
In some cases i have to hide a sheet depending on user selection and i used package.Workbook.Worksheets[1].Hidden = eWorkSheetHidden.Hidden or VeryHidden.
If i send the file with a sheet Hidden and open it, Excel show it but as i print preview the application crashes.
If instead of print preview i save the file to desktop, close excel and re-open it again and print preview, 90% cases no error.
Luckily (for me) i can delete the sheet instead of hiding, so i bypass the problem; however i wanted to detail it.
thanks,
Fabrizio
Comments: I compared XML code saved from EPPlus to Excel and found that <workbookView ...> in workbook.xml is missing firstSheet="1" activeTab="1". When we hide anything but the first worksheet, Excel figures it out. But if we hide the first one - it doesn't understand. I added this into the saved EPPlus file manually and it fixed the bug. I'll leave code implementation to the other developers.