我想导出HTML表MVC脱颖而出。 我在我的控制器下面的代码:
public JsonResult ExportToExcel(Control ctl)
{
Response.Clear();
Response.ContentType = "application/ms-excel";
Response.AddHeader("content-disposition", "attachment;filename=ExcelCopy.xls");
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
ctl.RenderControl(hw);
Response.Write(sw.ToString());
Response.End();
return Json(1);
}
和jQuery中的follwing功能:
function btnConvertToExcelClick() {
var inputParamtrs={ ????????? }
$.ajax({
type: "POST",
url: "/Expenses/ExportToExcel",
data: inputParamtrs,
success: function (json) {
}
});
return false;
}
我猜即时试图问的是如何将整个HTML表格传递给JsonResult功能的控制 。 救命!