This project has moved. For the latest updates, please go here.

test.xlsx couldn't be downloaded - EPPlus

Dec 11, 2012 at 5:03 PM

When I try to open test.xlsx created by the code below, I get "test.xlsx couldn't be downloaded". That said, if I choose to save the file, I am able to save and open the file just fine.

Please let me know what I am doing wrong.


    Dim pack As New ExcelPackage
    Dim ws As ExcelWorksheet = pack.Workbook.Worksheets.Add("Sheet1")
    Dim ms As New MemoryStream
    Dim dt As New DataTable

    ws.Cells(1, 1).Value = "Test"



    Context.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
    Context.Response.AddHeader("Content-Disposition", "attachment;filename=test.xlsx")
    Context.Response.StatusCode = 200
Dec 11, 2012 at 6:07 PM

It seems like you are calling Response.Clear() after you have written to the Outputstream?

Dec 11, 2012 at 8:26 PM

@swmal I tried it, but it did not work.

Dec 12, 2012 at 5:17 PM

In the source code there is a sample that describes how you can use EPPlus in ASP.NET (also available if you download the samples).