public ActionResult ExportLeadTimingReport(JLRReportSearchCriteriaViewModel searchCriteria)
{
OperationResponse<DataTable> LeadTimingReport = new OperationResponse<DataTable>();
LeadTimingReport.Value = new DataTable();
byte[] file = LeadManager.GetJLRLeadTimingReportForExport(searchCriteria);
HttpContext.Response.ClearContent();
HttpContext.Response.Clear();
HttpContext.Response.Buffer = true;
HttpContext.Response.AddHeader("content-disposition", "attachment; filename=Export.xlsx");
HttpContext.Response.ContentType = "application/force-download";
HttpContext.Response.Charset = "";
HttpContext.Response.BinaryWrite(file);
HttpContext.Response.End();
return null;
}
返回空的excel文件。但是二进制数组包含数据,但是当它被调用时它会给出空白的excel文件。
答案 0 :(得分:1)
请修改下面给出的代码
public ActionResult ExportLeadTimingReport(JLRReportSearchCriteriaViewModel searchCriteria)
{
OperationResponse<DataTable> LeadTimingReport = new OperationResponse<DataTable>();
LeadTimingReport.Value = new DataTable();
byte[] file = LeadManager.GetJLRLeadTimingReportForExport(searchCriteria);
this.Response.ContentType = "application/vnd.ms-excel";
return File(file , "application/vnd.ms-excel");
}