6
tôi phải dữ liệu xuất khẩu để xem như Excel, Thật sự tôi đã thực hiện, nhưng nghi ngờ của tôi là khi sử dụngXuất khẩu File Excel để xem (MVC)
return new FileContentResult(fileContents, "application/vnd.ms-excel");
vs
return File(fileContents, "application/vnd.ms-excel");
và Cách đặt Tên tệp có thể tải xuống theo từng phương pháp này?
Ví dụ 1:
public ActionResult ExcelExport()
{
byte[] fileContents = Encoding.UTF8.GetBytes(data);
return new FileContentResult(fileContents, "application/vnd.ms-excel");
}
Ví dụ: 2
public ActionResult ExcelExport()
{
byte[] fileContents = Encoding.UTF8.GetBytes(data);
return File(fileContents, "application/vnd.ms-excel");
}