寻求分页打印组件或代码,事成百分相送!

shauykee 2003-10-20 10:16:08
如题,望各位大虾踊跃相助,定当高分回报!
...全文
60 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
ltf1980 2004-03-22
  • 打赏
  • 举报
回复
mark
coolboy0000love 2003-10-23
  • 打赏
  • 举报
回复
<a href="javascript:window.print();"><B><FONT color=#003366>打印这条信息</font></B></A>


=====================================
<a href='javascript:doprint();'><img src="/news/images/v_prinf.GIF" border="0"></a>

====================================================

http://www.meadroid.com/scriptx/docs/printdoc.htm?static

有详细说明

<script defer>

function SetPrintSettings() {

// -- advanced features

factory.printing.SetMarginMeasure(2) // measure margins in inches

factory.SetPageRange(false, 1, 3) // need pages from 1 to 3

factory.printing.printer = "HP DeskJet 870C"

factory.printing.copies = 2

factory.printing.collate = true

factory.printing.paperSize = "A4"

factory.printing.paperSource = "Manual feed"



// -- basic features

factory.printing.header = "This is MeadCo"

factory.printing.footer = "Advanced Printing by ScriptX"

factory.printing.portrait = false

factory.printing.leftMargin = 1.0

factory.printing.topMargin = 1.0

factory.printing.rightMargin = 1.0

factory.printing.bottomMargin = 1.0

}



function Print(frame) {

factory.printing.Print(true, frame) // print with prompt

}

</script>






Top

回复人: nik_Amis(Azrael) ( ) 信誉:100 2003-1-20 12:55:17 得分:0


up


Top

回复人: meizz(梅花雨疏影横斜) ( ) 信誉:391 2002-9-20 11:43:14 得分:0


<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>

<input type="button" onClick="document.all.WebBrowser.ExecWB(7,1)" value="打印预览">



用JS直接设定不大可能!!


Top

回复人: onestab(一刺) ( ) 信誉:130 2002-9-20 11:44:07 得分:0


打印有浏览器负责。

还有第三方控件可用,单用javascript做不到。

页面内部的边距可由CSS控制。


Top

回复人: qiushuiwuhen(秋水无恨) ( ) 信誉:175 2002-9-20 13:22:31 得分:30


<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>



<title>呵呵</title>

<input type="button" value="页面设置"

onclick="factory.printing.PageSetup()">

<input type="button" value="打印预览"

onclick="factory.printing.Preview()">



<script>

function window.onload() {

factory.printing.header = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页"

factory.printing.footer = "(自定义页脚)"

factory.printing.leftMargin = 0.75

factory.printing.topMargin = 1.5

factory.printing.rightMargin = 0.75

factory.printing.bottomMargin = 1.5

}

</script>
=================================================


解决方案一:
<HTML><HEAD>
<script language="JavaScript">
var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
//设置网页打印的页眉页脚为空
function pagesetup_null()
{
try{
var RegWsh = new ActiveXObject("WScript.Shell")
hkey_key="header"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")
hkey_key="footer"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")
}catch(e){}
}
//设置网页打印的页眉页脚为默认值
function pagesetup_default()
{
try{
var RegWsh = new ActiveXObject("WScript.Shell")
hkey_key="header"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P")
hkey_key="footer"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d")
}catch(e){}
}
</script>
</HEAD>

<BODY><br/><br/><br/><br/><br/><br/><p align=center>
<input type="button" value="清空页码" onclick=pagesetup_null()>
<input type="button" value="恢复页码" onclick=pagesetup_default()><br/>
</p></BODY></HTML>
需要将ie安全级别降低,否则创建ActiveXObject对象时会报错。
解决方案二:
使用第三方免费控件
<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>
要降低ie的安全级别。

两种方案的缺点都是要降低ie的安全级别,如果不想降低,就不能在代码中实现,而要象上面一样手动更改了。





shauykee 2003-10-23
  • 打赏
  • 举报
回复
自己顶!
shauykee 2003-10-23
  • 打赏
  • 举报
回复
几天了,就没有热心高手能给完整点的?csdn的人都咋了?!
shauykee 2003-10-21
  • 打赏
  • 举报
回复
没有完整的回复了吗?这分怎么给啊??
showerXP 2003-10-20
  • 打赏
  • 举报
回复
涉及到查询条件、动态字段排序、分页状态等问题也能用一个什么类来解决吗?
lqflsh 2003-10-20
  • 打赏
  • 举报
回复
好像还有两个类没有贴出来。
wjhcjg 2003-10-20
  • 打赏
  • 举报
回复
第二页(打印页,注意和第一页相关时传的参数来控制分页打印):

<%Response.Expires=0%>
<!-- #INCLUDE FILE="../y_pro/rep.inc" -->
<!-- #INCLUDE FILE="../y_pro/SelectBmOne.inc" -->
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="stylesheet" type="text/css" href="home.css">
<title>打印基建维修申报单</title>
<style><!--
A:link {text-decoration: none; color: #000000}
A:visited {text-decoration: none; color: 000000}
A:active {text-decoration: none}
A:hover {text-decoration: underline; color: #ff0000;font-size:12pt}
td { font-size: 10pt; text-decoration: none}
body { font-family: "宋体"; font-size: 10pt; text-decoration: none}
--></style>
<style>
.tl {border:solid windowtext .5pt;}
.tmr {border:solid windowtext .5pt; border-left:none;}
</style>
</head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function printer() {
var temp=window.confirm('是否要打印工程技措汇总单?');
if (temp)
{
window.print();
//alert("已在打印中,可关闭窗口......")
//window.close();
}
else
{
window.close();
}
return temp;
}
//-->
</SCRIPT>
<body onload="printer();" topmargin="1" leftmargin="1" marginwidth="1" marginheight="1" bgcolor="#FFFFFF">

<p align="center">

<% set conn = db_Conn()
bm=trim(request("bm"))
nian=request("nian")
yue0=request("yue0")
if nian="" then nian=year(date())
if yue0="" then yue0=month(date())
if len(bm)=0 then
bm="00"
end if

if bm="00" or bm="" then
tempbm="所有部门"
else
set rss=conn.execute("select bmmc from bumen where bm='"&bm&"'")
tempbm=trim(rss("bmmc"))&"处"
rss.close
end if
%>
<%=nian%>年<%=yue0%>月<%=tempbm%>工程技措申报汇总
<table border="1" cellspacing="0" cellpadding="0" width="100%" bordercolorlight="#000000" style='border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; border-style: none; border-width: medium' bordercolordark="#000000">
<tr height="25">
<td width="35%" height="20" align="center" bgcolor="#EEEEEE">项目名称</td>

<td width="20%" height="20" align="center" bgcolor="#EEEEEE">申请单位</td>

<td width="15%" height="20" align="center" bgcolor="#EEEEEE">申报日期</td>

<td width="15%" height="20" align="center" bgcolor="#EEEEEE">预估费用</td>

<td width="15%" height="20" align="center" bgcolor="#EEEEEE">项目负责人</td>
</tr>
<%
str_nian=""
str_yue0=""
if yue0="" then
str_yue0=""
else
str_yue0=" and month(tbrq)="&yue0&" "
end if
if nian="" then
str_nian=""
else
str_nian=" and year(tbrq)="&nian&" "
end if

if len("bm")=0 or bm="00" then
sql="select xmmc,bumen.bmmc,tbrq,ygfy,users.name from gc_jcxm,users,bumen "
sql=sql&" where users.signon=gc_jcxm.xmfzr and bumen.bm=gc_jcxm.sqdw and gc_jcxm.sign='1' "
else
sql="select xmmc,bumen.bmmc,tbrq,ygfy,users.name from gc_jcxm,users,bumen "
sql=sql&" where gc_jcxm.sqdw='"&bm&"' and users.signon=gc_jcxm.xmfzr and bumen.bm=gc_jcxm.sqdw and gc_jcxm.sign='1' "
end if
sql=sql&str_nian&str_yue0&" order by tbrq desc "

Select Case Request.QueryString("pages")
Case ""
Session("Cpage") = 1
Case "Next"
Session("Cpage") = Session("Cpage") + 1
Case "Prev"
Session("Cpage") = Session("Cpage") - 1
End Select
Set RS = Server.CreateObject("ADODB.Recordset")
RS.PageSize =15
'response.write sql
RS.Open sql,conn,1
if not RS.eof then
if Session("Cpage")>rs.pagecount then
Session("Cpage")=rs.pagecount
else if Session("Cpage")<1 then
Session("Cpage")=15
end if
end if
RS.AbsolutePage = CLng(Session("Cpage"))
end if
%>

<%
i=1
do while (not RS.eof) and i <= RS.PageSize
%>
<tr height="25">
<td width="35%" height="20" align="center"><%=rs("xmmc")%></td>

<td width="20%" height="20" align="center"><%=rs("bmmc")%></td>

<td width="15%" height="20" align="center"><%=rs("tbrq")%></td>

<td width="15%" height="20" align="center"><%=rs("ygfy")%></td>

<td width="15%" height="20" align="center"><%=rs("name")%></td>
</tr>
<%i=i+1
RS.movenext
loop
%>
</table>
<%
RS.Close
Set conn = Nothing
%>
</form>
</body>

</html>


wjhcjg 2003-10-20
  • 打赏
  • 举报
回复
我给你代码,有两页,第一为查看页,第二页为查看页中点打印连接后的直接打印页:(代码长,我分两次回复,一次一页)

第一页代码:
<%Response.Expires=0%>
<!-- #INCLUDE FILE="../y_pro/rep.inc" -->
<!-- #INCLUDE FILE="../y_pro/SelectBmOne.inc" -->
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="stylesheet" type="text/css" href="home.css">
<title>用车申请</title>

</head>

<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<form name="fm" action="hz_gcjc.asp" method="post" style="display:inline">
<%
bm=trim(request("bm"))
nian=request("nian")
yue0=request("yue0")
if nian="" then nian=year(date())
if yue0="" then yue0=month(date())
if len(bm)=0 then
bm="00"
end if

set conn = db_Conn()
%>

<table border="0" cellspacing="1" width="100%" hspace="0" bgcolor="#FFFFFF" class=text>
<tr >
<td bgcolor="#66AAEE" valign="middle" align="center" height="30" colspan="11" width="662">
<%set rss=conn.execute("select bm,bmmc from bumen order by zzjb")%>
<p align="left">
 
<select name="nian" onchange="submit()">
<%for k=2003 to int(year(date()))+1%>
<%if nian="" then
if int(year(date()))=k then%>
<option value="<%=k%>" selected><%=k%></option>
<%else%>
<option value="<%=k%>"><%=k%></option>
<%end if%>
<%else
if k=int(nian) then%>
<option value="<%=k%>" selected><%=k%></option>
<%else%>
<option value="<%=k%>"><%=k%></option>
<%end if%>
<%end if%>
<%next%>
</select><font color="#FFFFFF">年</font>
<select name="yue0" onchange="submit()" size="1">
<%for i=1 to 12%>
<%if int(yue0)=i then%>
<option value="<%=i%>" selected><%=i%>月
<%else%>
<option value="<%=i%>"><%=i%>月 <%
end if
next
%>
</select><font color="#FFFFFF">月</font>
<select name="bm" onchange="submit()">
<%
if len("bm")=0 or bm="00" then
response.write "<option value='00' selected>----全部----"
else
response.write "<option value='00'>----全部----"
end if
do while not RSS.eof
if trim(bm)=trim(RSS("bm")) then
response.write "<option value='"&trim(RSS("bm"))&"' selected>"&trim(RSS("bmmc"))
else
response.write "<option value='"&trim(RSS("bm"))&"'>"&trim(RSS("bmmc"))
end if
RSS.movenext
loop
rss.close
%>
</select>
<%
str_nian=""
str_yue0=""
if yue0="" then
str_yue0=""
else
str_yue0=" and month(tbrq)="&yue0&" "
end if
if nian="" then
str_nian=""
else
str_nian=" and year(tbrq)="&nian&" "
end if

if len("bm")=0 or bm="00" then
sql="select gc_jcxm.id,xmmc,bumen.bmmc,tbrq,ygfy,users.name from gc_jcxm,users,bumen "
sql=sql&" where users.signon=gc_jcxm.xmfzr and bumen.bm=gc_jcxm.sqdw and gc_jcxm.sign='1' "
else
sql="select gc_jcxm.id,xmmc,bumen.bmmc,tbrq,ygfy,users.name from gc_jcxm,users,bumen "
sql=sql&" where gc_jcxm.sqdw='"&bm&"' and users.signon=gc_jcxm.xmfzr and bumen.bm=gc_jcxm.sqdw and gc_jcxm.sign='1' "
end if
sql=sql&str_nian&str_yue0&" order by tbrq desc "

Select Case Request.QueryString("pages")
Case ""
Session("Cpage") = 1
Case "Next"
Session("Cpage") = Session("Cpage") + 1
Case "Prev"
Session("Cpage") = Session("Cpage") - 1
End Select
set rs=server.createobject("adodb.recordset")
RS.PageSize =15
'response.write sql
RS.Open sql,conn,1
if not RS.eof then
if Session("Cpage")>rs.pagecount then
Session("Cpage")=rs.pagecount
else if Session("Cpage")<1 then
Session("Cpage")=15
end if
end if
RS.AbsolutePage = CLng(Session("Cpage"))
end if
%>
<font color="#FFFFFF">处工程技措项目(按申报日期汇总)</font>
<a href='#' title='打印汇总单' onClick=window.open('dy_gcjc.asp?nian=<%=nian%>&yue0=<%=yue0%>&bm=<%=bm%>&page=<%=CLng(Session("Cpage"))%>','report','scrollbars=yes,resizable=no,left=50,top=0,width=680,height=480')>[打印页面]</a>
</p>
</td>
</tr>
<tr bgcolor="#eeeeFF">
<td width="35%" height="20" align="center">项目名称</td>

<td width="20%" align="center">申请单位</td>
<td width="15%" align="center">申报日期</td>
<td width="15%" align="center">预估费用</td>
<td width="15%" align="center">项目负责人</td>
</tr>

<%
i=1
do while (not RS.eof) and i <= RS.PageSize
%>
<tr bgcolor="#eeeeFF">
<td width="35%" height="20" align="center" bgcolor="#CCCCFF">
<a href='#' title=查看此工程技措项目详情 onClick=window.open('dy_gcjc_detail.asp?id=<%=rs("id")%>','report','scrollbars=yes,resizable=no,width=700,height=520')>
<%=rs("xmmc")%></a>
</td>
<td width="20%" align="center" bgcolor="#CCCCFF"><%=rs("bmmc")%></td>
<td width="15%" align="center" bgcolor="#CCCCFF"><%=rs("tbrq")%></td>
<td width="15%" align="center" bgcolor="#CCCCFF"><%=rs("ygfy")%></td>
<td width="15%" align="center" bgcolor="#CCCCFF"><%=rs("name")%></td>
</tr>
<% i=i+1
RS.movenext
loop
%>
<tr bgcolor="#eeeeFF">
<td height="18" align="center" colspan="11" width="100%"> <font color="#0066ff">当前是第
<%=Session("Cpage")%> 页(共 <%=RS.PageCount%> 页, <%=RS.RecordCount%>
条)    </font>
<%If CLng(Session("Cpage")) > 1 Then %>
<a href="hz_gcjc.asp?pages=Prev"><< 前页</a>    
<%end if
If CLng(Session("Cpage")) < rs.PageCount Then %>
<a href="hz_gcjc.asp?pages=Next"> 下页 >></a>
<%End If%>
<a href=javascript:location.reload()>刷新</a>
</td>

</tr>
</table>
<%
RS.Close
Set conn = Nothing
%>
</form>
</body>

</html>
debug2003 2003-10-20
  • 打赏
  • 举报
回复
谢谢 上面的大虾 请发分完整的 到我的邮箱: zhangqiang_9761@163.com
谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢
谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢 谢谢
zhangqiang_9761@163.com
zhangqiang_9761@163.com
zhangqiang_9761@163.com

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧