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

前端 未结 5 2448

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:11

    I am exporting html table code which is in string variable HTML

    Following Code Working For Me

    byte[] myFile = Encoding.ASCII.GetBytes(HTML);
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("Content-Type", "application/excel");
            Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0};", "BAGrowthReport.xls"));
            Response.AddHeader("content-length", myFile.Length.ToString()); //Here is the additional header which is required for Chrome.
            Response.BinaryWrite(myFile);
            Response.Flush();
            Response.Close();
    

提交回复
热议问题