导出提交的页面加上:
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 onclick='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 onclick= "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="打印本页"
onclick="factory.printing.Print(false)">
<input id="idPrint2" type="button" value="页面设置"
onclick="factory.printing.PageSetup()">
<input id="idPrint3" type="button" value="打印预览"
onclick="factory.printing.Preview()">
<input id="idPrint4" type="button"
onclick="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" onclick="printReport()" value="打印">
<input type="button" onclick="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= "打印 " onclick= "javascript:printit() ">
<input type=button name=button_setup value= "打印页面设置 "onclick= "javascript:printsetup(); ">
<input type=button name=button_show value= "打印预览 " onclick= "javascript:printpreview(); ">
<input type=button name=button_fh value= "关闭 " onclick= "javascript:window.close(); ">