VahidN / EPPlus.Core

EPPlus.Core is an unofficial port of the EPPlus library to .NET Core
GNU Lesser General Public License v3.0
370 stars 93 forks source link

Does EPPLus ASP.NET Core support .Net Standard (not .Net Core) .Net framework 4.6.1 #46

Closed SanPangGitHub closed 6 years ago

SanPangGitHub commented 6 years ago

Summary of the issue

Can not open Export xlsx in ASP.NET Core 4.5.2 in browser using InMemoryReport I using .Net Standard (not .Net Core) in .Net Framework 4.6.1

Environment

backend: ASP.NET Core EPPlus, .Net Standard (not .Net Core) in .Net Framework 4.6.1 frontend: Chrome, angularjs

The in-use version:
Operating system: 
Win7, Visual studio 2017, 

## Example code/Steps to reproduce:
1. controller same with code example: 
HomeController.InMemoryReport()
{
            byte[] reportBytes;
            using (var package = createExcelPackage())
            {
                reportBytes = package.GetAsByteArray();
            }

            return File(reportBytes, XlsxContentType, "report.xlsx");
        }

2. Got web API response in front end to open excel in browser Chrome
response.data is the controller response.                
                    let blob = new Blob([response.data], {
                        type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
                    })
                    //To support IE 
                    if (navigator.appVersion.toString()
                        .indexOf('.NET') > 0)
                        window.navigator.msSaveBlob(blob, "report.xlsx");
                    //To support Chrome
                    else {
                        var a = document.createElement("a");
                        document.body.appendChild(a);
                        a.style = "display: none";
                        let url = window.URL.createObjectURL(blob);
                        a.href = url;
                        a.download = "report.xlsx";
                        a.click();
                        window.URL.revokeObjectURL(url);
                    }
                 });

## Output:
But it showed as:
"Excel cannot open the file... because the file format or file extension is not valid. Verify..corrupted and..."
I tried to change blob type to type: 'text/plain', but it does not work.

Exception message: Full Stack trace:

VahidN commented 6 years ago