ajax+jquery+NPOI导不出数据,在线等。。。
页面上导出按钮点击是触发的javascript方法:
function ExportData() {
$.ajax({
type: "post",
url: "../_Ajax/AjaxCountBase1.ashx",
data: 'op=Export',
dataType: "text",
cache: false,
success: function () {
},
error: function (message) {
LG.showError(message);
//$.ligerDialog.tip({ title: '提示信息', content: '导出失败' });
}
});
}
AjaxCountBase1.ashx里调用的方法:
protected void ExportExcel(HttpContext context)
{
if (ExportDataTable != null)
{
ExcelRender.RenderToExcel(
ExportDataTable,
context,
"统计.xls");
}
}
点导出后所有代码都正常运行 ExportDataTable 也是有数据的 但就是没反应 没有弹出要保存Excel的提示 --------------------编程问答-------------------- 这样应该不行的吧,弹出文件对话框是浏览器控制的,得让浏览器知道有文件要下载啊。
我是用新建一个隐藏的frame的方式实现的 --------------------编程问答--------------------
请问具体怎样实现啊 --------------------编程问答--------------------
--------------------编程问答--------------------
var downloadFrame;
function Download(src) {
// Check to be sure this async postback is actually
// requesting the file download.
if (!downloadFrame) {
downloadFrame = document.createElement("iframe");
// Add the IFRAME to the page. This will trigger
// a request to GenerateFile now.
document.body.appendChild(downloadFrame);
// This makes the IFRAME invisible to the user.
downloadFrame.style.display = "none";
}
// Point the IFRAME to GenerateFile, with the
// desired region as a querystring argument.
downloadFrame.src = src;
setTimeout("downloadFrame.src=''", 3000);
}
怎么用啊?
补充:.NET技术 , ASP.NET