All
How can I download a file so the user sees that it is downloading (like with a stream?)
I am currently using ClosedXML, but if I use the SaveAs method, I
If using Asp.Net MVC, basically the same but slightly neater (well I think so:)).
public ActionResult DownloadFile(XXXModel model)
{
using (var workbook = new XLWorkbook(XLEventTracking.Disabled))
{
// create worksheets etc..
// return
using (var stream = new MemoryStream())
{
workbook.SaveAs(stream);
stream.Flush();
return new FileContentResult(stream.ToArray(),
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
{
FileDownloadName = "XXXName.xlsx"
};
}
}