Last post Jan 20, 2017 10:10 AM by Basquiat
Jan 19, 2017 09:50 AM|Basquiat|LINK
I am using ASP.Net Core MVC with EPPlus to export to info to Excel.
It worked just fine until recently but now suddenly it doesn't create the Excel file but it also returns no error.
Stepping through in Debug reveals no problems and adding a try catch also catches no errors.
The code runs (when button is clicked on web page) but no Excel file is created .... any help how to fix or troubleshoot this?
public IActionResult Export()
using (ExcelPackage pck = new ExcelPackage())
var demo = "Some sample text.";
//Create the worksheet
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Index");
//Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
//Write it back to the client
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.Headers.Add("content-disposition", "attachment; filename=PropertiesExport.xlsx");
var bytes = pck.GetAsByteArray();
Response.Body.WriteAsync(bytes, 0, bytes.Length);
Jan 20, 2017 09:30 AM|ignatandrei|LINK
Please debug and see the value of
Jan 20, 2017 10:10 AM|Basquiat|LINK
Thanks for the reply.
This did return the number bytes as it should.
I managed to fix it by changing it to an await
await Response.Body.WriteAsync(bytes, 0, bytes.Length);