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

前端 未结 5 2399

I try to download an excel file made by EPPlus.dll from an asp.net c# web form application. but i get Failed - network error. It should be noted that mentioned erro

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-20 00:18

    Try this:

    using (ExcelPackage p = new ExcelPackage())
    {
        //Code to fill Excel file with data.
    
    
        Byte[] bin = p.GetAsByteArray();
    
        Response.ClearHeaders();
        Response.ClearContent();
        Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
        Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", Nombre_Del_Libro + ".xlsx"));
        Response.BinaryWrite(bin);
        Response.Flush();
        Response.End();
    }   
    

提交回复
热议问题