Reza Amini Reza Amini - 10 months ago 335
ASP.NET (C#) Question

Failed - network error when downloading excel file made by EPPlus.dll

I try to download an excel file made by

from an c# web form application. but i get Failed - network error.
It should be noted that mentioned error just occurs in chrome and the job can be done successfully in another browsers.

by the way this error does not occure on my localhost and it happens only on the main server.

It would be very helpful if someone could explain solution for this problem.

enter image description here

Answer Source

Try this:

using (ExcelPackage p = new ExcelPackage())
    //Code to fill Excel file with data.

    Byte[] bin = p.GetAsByteArray();

    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", Nombre_Del_Libro + ".xlsx"));