[HttpPost]
public ActionResult ExportTableToExcel(string htmlTable)
{
EFWPResponse Result = new EFWPResponse() { RequestStatus = false };
try
{
Response.AppendHeader("content-disposition", "attachment;filename=FileEName.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
//this.EnableViewState = false;
Response.Write(htmlTable);
Response.End();
}
catch (Exception ex)
{
ModelState.AddModelError("", ex);
}
return Json(Result);
}
// 代码执行成功,但没有打开 excel 文件。//任何人都可以请做什么来生成用jquery在C#中打开的Excel文件。