我需要導出HTMLTABLE爲XLS,使用jquery時無法將htmltable導出爲xls文件?
我有大量使用jQuery和有一個鏈接頁面觸發一個jQuery後
var downloadType = document.getElementById("downloadType");
var downloadTypeValue = downloadType.options[downloadType.selectedIndex].value;
var data = {
exportFormat: downloadTypeValue
};
$.post("ajax.aspx",data);
,你可以看到,該鏈接後的文件格式爲頁面命名ajax.aspx它運行下面的代碼
HtmlTable tableToExport = (HtmlTable)Session["tblReportResult"];
StringWriter stringWrite = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
tableToExport.RenderControl(htmlWrite);
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=wateva.xls");
Response.ContentType = "application/ms-excel";
Response.Write(stringWrite.ToString());
Response.End();
所以從會話檢索HTMLTABLE控制和使用Response.Write生成文件,但是,它不工作...任何想法嗎?
如果您發佈完整的答案,它可以幫助其他人...... – tostasqb 2013-08-07 17:12:30