I have to Export Data to View as Excel , Actually I have Implemented,but my doubt is when to use
return new FileContentResult(fileContents, "application/vnd.ms-excel");
vs
return File(fileContents, "application/vnd.ms-excel");
and How can set Downloadable Filename in each of this 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");
}