var oHttpReq = new ActiveXObject("MSXML2.XMLHTTP");
//导出
function Export()
{
var o = document.getElementById("ExportFlag"); //页面上的导出标识,在此无实际意义
if (confirm('导出可能需要几分钟,确定导出吗?'))
{
o.value = "1";
document.getElementById("promptDiv").style.display = "";//导出进度条的显示
var v1 = document.getElementById("enosValue").value;//传出参数1
var v2 = document.getElementById("cersIdsValue").value; //参数2
var url = "Export.aspx?eno="+v1+"&cerId="+v2+""; //设置URL
oHttpReq.open("POST",url , true);
oHttpReq.onreadystatechange = handleStateChange; //绑定事件
oHttpReq.setRequestHeader("Content-Type","application/octet-stream;charset=utf-8"); //设定内容的编码形式
oHttpReq.send(""); }
else
{
o.value = "0";
return false;
}
document.getElementById("method").value=""; //页面上的input控件
return true;
}
function handleStateChange()
{
if( oHttpReq.readyState == 4 )
{
if( oHttpReq.status == 200 )
{
var o = document.getElementById("ExportFlag");
o.value = "0";
var result = oHttpReq.responseText;
var d = document.getElementById("promptDiv");
d.style.display = "none";
if(result == "0")
{
alert('导出excel失败!');
}
else if(result == "1")
{
alert('没有可以导出的数据!');
}
else
{
var m,f,v;
var lbs = document.getElementById("Label3");
var a = "<a href=\""+ result+"\" id=\"a1\" class=\"bl\" target=_blank><u>右击另存为保存报告(临时)</u></a>";
lbs.innerHTML=a;
var opa = document.getElementById("a1");
savepic(result)
return true;
}
}
else
{
alert( "处理完毕!");
}
}
}
//打开保存对话框
function savepic(href)
{
if(document.all.ax==null)
{
objIframe=document.createElement("IFRAME");
document.body.insertBefore(objIframe);
objIframe.outerHTML= "<iframe name='ax' style='width:0;hieght:0' src="+href+"></iframe>";
var str = "savepic("+href+")";
re=setTimeout(str,1) ;
}
else
{
clearTimeout(re) ;
pic = top.main.open(href,"ax");
pic.document.execCommand("SaveAs") ;
document.all.ax.removeNode(true) ;
}
}