I need to export data for viewing as Excel, I actually implemented it, but I doubt when to use
return new FileContentResult(fileContents, "application/vnd.ms-excel");
against
return File(fileContents, "application/vnd.ms-excel");
and How to set the downloadable file name in each of these methods?
Example 1:
public ActionResult ExcelExport() { byte[] fileContents = Encoding.UTF8.GetBytes(data); return new FileContentResult(fileContents, "application/vnd.ms-excel"); }
Example: 2
public ActionResult ExcelExport() { byte[] fileContents = Encoding.UTF8.GetBytes(data); return File(fileContents, "application/vnd.ms-excel"); }
source share