I’m trying to output a ExcelPackage created using EPPLUS to a file path without Excel actually opening up the file. I’ve got the below code right now…what am I doing wrong? Thanks.
Dim FileName As String = "C:\Temp\" + CurrAcct + ".xlsx"
Dim Result As New MemoryStream()
xlPackage.SaveAs(Result)
Context.Response.Clear()
Context.Response.ContentType = "application/vnd.openxmlformats- officedocument.spreadsheetml.sheet"
Context.Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName + ".xlsx")
Result.WriteTo(Context.Response.OutputStream)
Context.Response.End()
You need to use a FileStream to save it to the local disk.
Here is a stackoverflow example: Save as using EPPlus?