Closed mskuratowski closed 7 years ago
GetAsByteArray
, it's not necessary to pass a MemoryStream
to the ExcelPackage
. Just use it directly.MemoryStream
, you should call package.Save()
and package.Dispose()
, before accessing the memoryStream.ToArray()
method. Otherwise the final file will contain the whole buffer (including garbage bytes) and that's why Microsoft Excel reports it's corrupted (because the result contains a larger buffer than it should be).I still can not open the file. Maybe that's why because I use a docker ?
You know what, it works fine. The problem is when I test an app using Swagger.
To sum up, everything is okay. Thanks
I'm trying to export XLSX file in ASP.NET Core using EPPlus.Core library.
Here's my code:
It was successfully exported a file but there is an error message when I try to open a file using Microsoft Excel I'm getting an error message:
and after I click "Yes" button, I'm getting an error message:
Moreover, I tried to unzip the xslx file and I'm getting an error message: "Can not open the file as [zip] archive. Is not archive. Warnings: Headers Error".
Also, I opened a generated file using notepad++ and it starts with "PK", so it's a zip file.
When I generate an Excel file and save it to the wwwroot folder it works fine. I used a code from talkingdotnet.com/import-export-xlsx-asp-net-core
Do you have any idea how can I solve this problem?