1

Here is the important part, called from an AJAX call in the view:

 using (ExcelPackage pck = new ExcelPackage())
        {
            ExcelWorksheet ws = pck.Workbook.Worksheets.Add(fileName);
            ws.Cells["A1"].LoadFromDataTable(dt, true);
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("content-disposition", "attachment;  filename=" + fileName + ".xlsx");
            Byte[] bytes = pck.GetAsByteArray();
            Response.BinaryWrite(bytes);
            Response.End();
        }

But it creates an error: enter image description here

Any idea what is wrong?

Dean.DePue
  • 1,013
  • 1
  • 21
  • 45
  • What if you set some additional meta data like here: http://stackoverflow.com/questions/31123352/set-download-location-with-epplus ? Probably wont make a difference. Maybe post more of your code. – Ernie S Jun 29 '15 at 22:10
  • @Ernie thanks. I tried that and I'm getting the same error. – Dean.DePue Jun 30 '15 at 09:54
  • I answered this question but it had been moderated because of duplicating. Please refer: http://stackoverflow.com/questions/31127060/why-the-borwser-cant-show-an-epplus-spreadsheet . I have an answer there. When that question has an accepted answer, I will perform dupplicated-marking. Now, it's impossible. – Han Jul 01 '15 at 04:25

0 Answers0