SQL 查询数据打印并导出EXECL
?導出提交的頁面加上:
response.contenttype= "application/msexcel "
response.addheader ? "content-disposition ", "attachment;filename=export.xls "
打印: <span ? id=bt1> <input ? type= "submit " ? name= "Submit " ? value= "打印 "onClick= "javascript:bt1.innerHTML= ' ';window.print();return ? false; " ? style= "cursor:hand "> </span>
?
?
<%
if ? request( "action ")= "down " ? then
response.ContentType ? = "application/vnd.ms-excel "
Response.AddHeader ? "Content-Disposition ", ? "attachment; ? filename=1.xls "
end ? if
%>
<a ? href= "?action=down "> 保存成excel </a>
?
?
打印預覽框架里的內容
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" id="WebBrowser" width="0"></OBJECT>
<input name="Button" onClick="document.all.hiddenframe.ExecWB(7,1);" type="button" value="打印預覽">
<iframe frameborder="0" height="10%" width="100%" name="hiddenframe" src="test.htm"></iframe>
?
<body>
<input οnclick='prn()' type=button value=print_Iframe> <br>
<iframe id=mxh src="d:/hhh.htm"> </iframe>
<script>
function prn()
{
var win=window.open("about:blank")
win.moveTo(1200,1200)
win.location=document.all.mxh.src
win.print()
}
</script>
?
?
存在一個頁面:par.aspx存在一個iframe包含于par.aspx
iframe.id= "prnf "
iframe.name= "prnf "
iframe.src= "sprn.html "
?
<input ? οnclick= "window.frames[ 'prnf '].focus();window.frames[ 'prnf '].print(); ">
?
?
?
<SCRIPT? ? LANGUAGE=javascript>?
? function? ? button1_onclick()?
? {?
? ? var? ? odoc=window.right.document;?
? ? var? ? r=odoc.body.createTextRange();?
? ? var? ? stxt=r.htmlText;?
? ? alert(stxt)?
? ? var? ? pwin=window.open("","print");?
? ? pwin.document.write(stxt);?
? ? pwin.print();?
? }??
? function? ? button1_onclick2()
? {?
? ? var? ? oWin=window.open("")?
? ? oWin.document.write(top.right.document.body.outerHTML)?
? ? oWin.print();?
? ? oWin.location.reload();?
? ? oWin.close();
? }
</SCRIPT>
<input type="button" value="按鈕1" onClick="button1_onclick()"/>?
<input type="button" value="按鈕2" onClick="button1_onclick2()"/>?
<iframe frameBorder="0" id="right" name="right2" scrolling="auto" src="panel_index.asp" style="HEIGHT: 96%; VISIBILITY: inherit; WIDTH: 100%; Z-INDEX: 1"> </iframe>
?
?
?
<head> ?
? <title>打印確認</title> ?
? <style ? media="print"> ?
? .noprint ? { ? display: ? none ? } ?
? </style> ?
? </head> ?
? <body> ?
? <object ? id="factory" ? style="display:none" ? viewastext ? classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" ? codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360"></object> ?
? <script ? defer> ?
? function ? window.onload() ? { ?
? ? ? //factory.printing.paperSize ? = ? "A3" ?
? ? ? factory.printing.header ? = ? "" ?
? ? ? factory.printing.footer ? = ? "" ?
? ? ? factory.printing.portrait ? = ? false ?
? ? ? idPrint1.disabled ? = ? false; ? // ? enable ? UI ? button ?
? ? ? idPrint2.disabled ? = ? false; ?
? ? ? idPrint3.disabled ? = ? false; ?
? ? ? idPrint4.disabled ? = ? false; ?
? ? ? factory.printing.leftMargin ? = ? 0.75 ?
? ? ? factory.printing.topMargin ? = ? 1.5 ?
? ? ? factory.printing.rightMargin ? = ? 0.75 ?
? ? ? factory.printing.bottomMargin ? = ? 1.5 ?
? ? ? } ?
? </script> ?
? <div ? class=noprint> ?
? ? ? <input ? id="idPrint1" ? type="button" ? value="打印本頁" ?
? ? οnclick="factory.printing.Print(false)"> ?
? ? ? <input ? id="idPrint2" ? type="button" ? value="頁面設置" ?
? ? οnclick="factory.printing.PageSetup()"> ?
? ? ? <input ? id="idPrint3" ? type="button" ? value="打印預覽" ?
? ? οnclick="factory.printing.Preview()"> ?
? ? ? <input ? id="idPrint4" ? type="button" ?
? ? οnclick="window.close()" ? value="關閉窗口"> ?
? </div> ?
? <br/> ?
? <table ? width="720" ? border="0" ? cellspacing="0" ? cellpadding="0" ? align="center" ? > ?
? ? ? <tr> ? ?
? ? ? ? ? <td ? ? bgcolor="#0099ff"> ?
? ? ? ? 這里是你要打印的內容,上面的按鈕不會被打印出來<br/> ?
? ? ? ? factory.printing.paperSize ? = ? "A3" ?
? ? ? ? </td> ?
? </tr></table></body>???
?
?
?
<!--這里調用控件ScriptX.cab-->
<object id="factory" style="DISPLAY: none" viewastext classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="http://www.a.com/smsx.cab#Version=6,3,434,26"></object>
<SCRIPT defer>
//用于設置打印參數
function printBase() {
factory.printing.footer = "頁眉"?? //頁眉
factory.printing.footer = "頁腳"?? //頁腳
factory.printing.portrait = false?? //true為縱向打印,false為橫向打印
factory.printing.leftMargin = 1.5?? //左頁邊距
factory.printing.topMargin = 0.5?? //上頁邊距
factory.printing.rightMargin = 0.5?? //右頁邊距
factory.printing.bottomMargin = 1.0?? //下頁邊距
}
//用于調用設置打印參數的方法和顯示預覽界面
function printReport(){
??????? printBase();
??????? //window.print();
??????? factory.printing.Preview();
}
//使界面最大化
maxWin();
function maxWin()
{
????? var aw = screen.availWidth;
????? var ah = screen.availHeight;
????? window.moveTo(0, 0);
????? window.resizeTo(aw, ah);
}
</SCRIPT>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bordercolor="#FFFFFF">
?? <tr bordercolor="#FFFFFF">
???? <td >
??????? <table width="70%" border="0" cellspacing="0" cellpadding="2" align="center">
????????? <tr>
??????????? <td align="center"><font size="5" face="宋體"><b>查詢打印</b></font></td>
????????? </tr>
????????? <tr>
??????????? <td align="center">
????????????? <div id="divReport" name="divReport">
????????????? <input type="button" name="cmdPRINT" id="cmdPRINT" οnclick="printReport()" value="打印">
?????????????
????????????? <input type="button" οnclick="window.close();"?? value="關閉">
????????????? </div>
??????????? </td>
????????? </tr>
??????? </table>
??? </td>
?? </tr>
</table>
</body>
</html>
?
?
?
?
<script ? language= "javascript "> ? ?
function ? printsetup(){ ? ?
// ? 打印頁面設置 ? ?
wb.execwb(8,1); ? ?
} ? ?
function ? printpreview(){ ? ?
// ? 打印頁面預覽 ? ?
? ?
wb.execwb(7,1); ? ?
? ?
? ?
} ? ?
function ? printit() ? ?
{ ? ?
if ? (confirm( '確定打印嗎? ')) ? { ? ?
wb.execwb(6,6) ? ?
} ? ?
} ? ?
</script> ? ?
</head> ? ?
<body> ? ?
<OBJECT ? classid= "CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 " ? height=0 ? id=wb ? name=wb ? width=0> </OBJECT>
<table>
<tr> <td> 數據 </td> </tr>
<tr> <td> 數據 </td> </tr>
<tr> <td> 數據 </td> </tr>
<tr> <td> 數據 </td> </tr>
<tr> <td> 數據 </td> </tr>
<tr> <td> 數據 </td> </tr>
</table> ?
<input ? type=button ? name=button_print ? value= "打印 " ? ? οnclick= "javascript:printit() "> ? ?
<input ? type=button name=button_setup ? value= "打印頁面設置 ? "οnclick= "javascript:printsetup(); "> ? ?
<input ? type=button name=button_show ? value= "打印預覽 " ? οnclick= "javascript:printpreview(); "> ? ?
<input ? type=button ? name=button_fh ? value= "關閉 "???? οnclick= "javascript:window.close(); ">
總結
以上是生活随笔為你收集整理的SQL 查询数据打印并导出EXECL的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 十大流氓骚扰软件卸载秘籍
- 下一篇: 灰鸽子木马的原理和清除方法