23 个解决方案
#1
可以使用ie进行打印
<style>
@media print {
.ipt {display:none}
}
</style>
<object ID="WebBrowser1" WIDTH="0" HEIGHT="0"
CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<input type=button class="ipt" name=print value="打印" onclick="WebBrowser1.ExecWB(6,1)">
<input type=button class="ipt" name=print value="打印预览" onclick="WebBrowser1.ExecWB(7,1)">
<input type=button class="ipt" name=print value="页面设置" onclick="WebBrowser1.ExecWB(8,1)">
可以研究一下css控制,微软的网站上有讲到.
<style>
@media print {
.ipt {display:none}
}
</style>
<object ID="WebBrowser1" WIDTH="0" HEIGHT="0"
CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<input type=button class="ipt" name=print value="打印" onclick="WebBrowser1.ExecWB(6,1)">
<input type=button class="ipt" name=print value="打印预览" onclick="WebBrowser1.ExecWB(7,1)">
<input type=button class="ipt" name=print value="页面设置" onclick="WebBrowser1.ExecWB(8,1)">
可以研究一下css控制,微软的网站上有讲到.
#2
商业化的可选一些打印控件,不过大部分要钱的
免费的不太好用
免费的不太好用
#3
可以生成word文件直接在IE里面调入word,操作就是word的事了!
#4
利用ie只能打印当前显示出来的页,不能打印记录集中的其它页(通过"翻页"按钮在网页上显示出来),而用word或excel又要求用户必须安装有office.有没有其它方法呀?
#5
看看,没试过:
http://expert.csdn.net/Expert/topic/1978/1978459.xml?temp=4.755801E-02
http://expert.csdn.net/Expert/topic/1978/1978459.xml?temp=4.755801E-02
#6
看看,没试过:
http://expert.csdn.net/Expert/topic/1978/1978459.xml?temp=4.755801E-02
http://expert.csdn.net/Expert/topic/1978/1978459.xml?temp=4.755801E-02
#7
我搞错了!我也是到1号才放假的!!不好意思!你放心的来吧!不用担心的!
我下班了!!大脑中一篇空白!没有能量了!真的没有!
我下班了!!大脑中一篇空白!没有能量了!真的没有!
#8
"http://expert.csdn.net/Expert/topic/1978/1978459.xml?temp=4.755801E-02"中的介绍的文章只适合html与服务器脚本混合生成的Web打印,而我现在的前端是通过servlet类生成纯html后返回的,故难以解决分页打印及给每页加上同一标题这一问题
#9
生成PDF文件打印
#10
to usa112233
如何生成pdf文件?
如何生成pdf文件?
#11
<style>
div.page { page-break-after: always }
@media print{
select {display:none}
.noprint {display:none}
}
</style>
<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 language=javascript>
function window.onload()
{
factory.printing.header = "&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
}
function view(){
factory.printing.Preview();
}
function doprint(){
window.print();
}
</script>
div.page { page-break-after: always }
@media print{
select {display:none}
.noprint {display:none}
}
</style>
<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 language=javascript>
function window.onload()
{
factory.printing.header = "&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
}
function view(){
factory.printing.Preview();
}
function doprint(){
window.print();
}
</script>
#12
to flymoods(放飞心情)
免费的ScriptX.cab组件不能通过Javascript来控制"纸张类型"及"打印方向"
免费的ScriptX.cab组件不能通过Javascript来控制"纸张类型"及"打印方向"
#13
可以呀,我当前用的就可以,可以设置大小和打印方向,还可以设置表头和表尾!
#14
还有,我用的这个打印的东西需要用IE6!如果必要的话我可以给你一个列子。
#15
to flymoods(放飞心情)
我的IE也是V6,请给一个比较详细的例子,谢!
我的IE也是V6,请给一个比较详细的例子,谢!
#16
用商业的如,方成的报表,就不错,用IE的太不灵活,
#17
那得要银子呀,呵呵!
#18
例子来了:
========================================
printSet.jsp
<style>
div.page { page-break-after: always }
@media print{
select {display:none}
.noprint {display:none}
}
</style>
<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 language=javascript>
function window.onload()
{
factory.printing.header = "&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
}
function view(){
factory.printing.Preview();
}
function doprint(){
window.print();
}
</script>
=============================================
下面是具体用打印的jsp
<%@ page contentType="text/html; charset=gb2312" %>
<jsp:useBean id="saleReport" scope="page" class="com.eachtand.qunxing.report.SaleReport" />
<jsp:useBean id="dateDealWith" scope="page" class="com.eachtand.common.util.DateDealWith" />
<%
//引进printSet.jsp文件
%>
<%@include file = "../common/printSet.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../../css/general.css" rel="stylesheet" type="text/css">
<script src="../../js/Mouse.js"></script>
<script language=javaScript >
//弹出模式窗口,查询界面
var k;
var s = new Object();
function saleSearch(){
k = showModalDialog('saleSearch.jsp',s,'dialogHeight:210px;dialogWidth:600px;status:no;help:no');
if(k!=null){
form1.beginDate.value=k.beginDate;
form1.endDate.value=k.endDate;
form1.department.value=k.department;
form1.operater.value=k.operater;
form1.carType.value=k.carType;
form1.submit();
}
}
</script>
</head>
<%
String sBeginDate=request.getParameter("beginDate");//得到查询条件开始时间
if(sBeginDate==null && sBeginDate==null)
sBeginDate="";
String sEndDate=request.getParameter("endDate");//得到查询条件结束时间
if(sEndDate==null)
sEndDate="";
String sDepartment=request.getParameter("department");//得到查询条件部门
if(sDepartment==null)
sDepartment="";
String sOperater=request.getParameter("operater");//得到查询条件业务员
if(sOperater==null)
sOperater="";
String sCarType=request.getParameter("carType") ;//得到查询条件汽车类型
if(sCarType==null)
sCarType="";
%>
<body bgcolor="EAF1FB" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div class="toptable"><spacer type=block height=1></div>
<form name="form1" method="post">
<table width="90%" height="214" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="left" class="tableTitle"> </td>
<td align="center" >
<div class="noprint">
<img style="cursor:hand" src="../../images/queryblank.gif" onClick="saleSearch()" onMouseOver="showImage(this,'../../images/querycolor.gif')" onMouseOut="showImage(this,'../../images/queryblank.gif')" >查
询 <img style="cursor:hand" src="../../images/printviewblank.gif" name="pre_print" value="打印预览" onClick = "view()" onMouseOver="showImage(this,'../../images/printviewcolor.gif')" onMouseOut="showImage(this,'../../images/printviewblank.gif')" >打印预览
<img src="../../images/printblank.gif" name="print" width="28" height="22" style="cursor:hand" onClick = "doprint()" onMouseOver="showImage(this,'../../images/printcolor.gif')" onMouseOut="showImage(this,'../../images/printblank.gif')" value="打 印" >打
印</div></td>
<td align="left" > </td>
</tr>
<tr>
<td height="28" colspan="2" align="center" ><font size="3">北方群星销售报表</font></td>
<td align="left" > </td>
</tr>
<tr>
<td width="294" height="26" align="left" >统计时间:
<%
if(sBeginDate.equals("") && sEndDate.equals("")){
%>
<input type="text" name="date1" size="24" class="bottomline" value="从<%=dateDealWith.getCurrentDate()%>到<%=dateDealWith.getCurrentDate()%>">
<%
}else{
%>
<input type="text" name="date1" size="24" class="bottomline" value="从<%=sBeginDate%>到<%=sEndDate%>">
<%
}
%>
</td>
<td width="260" align="left" ><div align="right">制作时间:
<input type="text" name="date2" size="10" class="bottomline" value="<%=dateDealWith.getCurrentDate()%>">
</div></td>
<td width="128" align="left" > </td>
</tr>
<tr>
<td height="98" colspan="2"> <table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="e3e1e2">
<tr>
<td bgcolor="336799"><div align="center"><font color="#FFFFFF" >业务类型</font></div></td>
<td height="23" bgcolor="336799"> <div align="center"><font color="#FFFFFF">数量(辆)</font></div></td>
</tr>
<tr>
<td bgcolor="F4F3DF"><div align="center">整车</div></td>
<%
//统计整车销售数量
int iAllSaleNum=saleReport.allSaleStatistics(sBeginDate,sEndDate,sCarType,sDepartment,sOperater);
if(iAllSaleNum>0){
%>
<td height="22" bgcolor="F4F3DF" align="center"><a href="allSaleReportList.jsp?sBeginDate=<%=sBeginDate%>&sEndDate=<%=sEndDate%>&sCarType=<%=sCarType%>&sDepartment=<%=sDepartment%>&sOperater=<%=sOperater%>"><font color="#000000" ><%=iAllSaleNum%></font></a></td>
<%
}else{
%>
<td height="22" bgcolor="F4F3DF" align="center"><font color="#000000" ><%=iAllSaleNum%></font></td>
<%
}
%>
</tr>
<tr>
<td bgcolor="FFFFF3"><div align="center">分期车</div></td>
<%
//统计分期车销售数量
int iDivConctractCarSaleNum=saleReport.divConctractCarSaleStatistics(sBeginDate,sEndDate,sCarType,sDepartment,sOperater);
if(iDivConctractCarSaleNum>0){
%>
<td height="24" bgcolor="FFFFF3" align="center"><a href="divConctractCarSaleList.jsp?sBeginDate=<%=sBeginDate%>&sEndDate=<%=sEndDate%>&sCarType=<%=sCarType%>&sDepartment=<%=sDepartment%>&sOperater=<%=sOperater%>"><font color="#000000" ><%=iDivConctractCarSaleNum%></font></a></td>
<%
}else{
%>
<td height="24" bgcolor="FFFFF3"> <div align="center"><font color="#000000" ><%=iDivConctractCarSaleNum%></font></div></td>
<%
}
%>
</tr>
<tr bgcolor="#F4F3DF">
<td><div align="center"><font color="#000000">合计</font></div></td>
<td height="23"> <div align="center"><%=iAllSaleNum+iDivConctractCarSaleNum%></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="27"> </td>
<td height="27"><div align="right">制作人:
<input type="text" size="10" name="makePerson" value="XXX" class="bottomline">
</div></td>
</tr>
</table>
<input type="hidden" name="beginDate" value="<%=sBeginDate%>">
<input type="hidden" name="endDate" value="<%=sEndDate%>">
<input type="hidden" name="department" value="<%=sDepartment%>">
<input type="hidden" name="operater" value="<%=sOperater%>">
<input type="hidden" name="carType" value="<%=sCarType%>">
</form>
</body>
</html>
======================================================================
说明:
1.在打印的页面里首先要引入的jsp(也可以是其它的格式:text等):printSet.jsp
2.调用printSet.jsp的view()方法可以打印览,调用doprint()可以打印,在打印印览时可以设置纸张大小和横打还是竖打,其实调用的就是window中的打印印览。
3.如果在打印中不想打印某一部分,可以隐藏。采用printSet.jsp中的style格式:
<div class="noprint">
要隐藏的内容
</div>
========================================
printSet.jsp
<style>
div.page { page-break-after: always }
@media print{
select {display:none}
.noprint {display:none}
}
</style>
<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 language=javascript>
function window.onload()
{
factory.printing.header = "&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
}
function view(){
factory.printing.Preview();
}
function doprint(){
window.print();
}
</script>
=============================================
下面是具体用打印的jsp
<%@ page contentType="text/html; charset=gb2312" %>
<jsp:useBean id="saleReport" scope="page" class="com.eachtand.qunxing.report.SaleReport" />
<jsp:useBean id="dateDealWith" scope="page" class="com.eachtand.common.util.DateDealWith" />
<%
//引进printSet.jsp文件
%>
<%@include file = "../common/printSet.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../../css/general.css" rel="stylesheet" type="text/css">
<script src="../../js/Mouse.js"></script>
<script language=javaScript >
//弹出模式窗口,查询界面
var k;
var s = new Object();
function saleSearch(){
k = showModalDialog('saleSearch.jsp',s,'dialogHeight:210px;dialogWidth:600px;status:no;help:no');
if(k!=null){
form1.beginDate.value=k.beginDate;
form1.endDate.value=k.endDate;
form1.department.value=k.department;
form1.operater.value=k.operater;
form1.carType.value=k.carType;
form1.submit();
}
}
</script>
</head>
<%
String sBeginDate=request.getParameter("beginDate");//得到查询条件开始时间
if(sBeginDate==null && sBeginDate==null)
sBeginDate="";
String sEndDate=request.getParameter("endDate");//得到查询条件结束时间
if(sEndDate==null)
sEndDate="";
String sDepartment=request.getParameter("department");//得到查询条件部门
if(sDepartment==null)
sDepartment="";
String sOperater=request.getParameter("operater");//得到查询条件业务员
if(sOperater==null)
sOperater="";
String sCarType=request.getParameter("carType") ;//得到查询条件汽车类型
if(sCarType==null)
sCarType="";
%>
<body bgcolor="EAF1FB" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div class="toptable"><spacer type=block height=1></div>
<form name="form1" method="post">
<table width="90%" height="214" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="left" class="tableTitle"> </td>
<td align="center" >
<div class="noprint">
<img style="cursor:hand" src="../../images/queryblank.gif" onClick="saleSearch()" onMouseOver="showImage(this,'../../images/querycolor.gif')" onMouseOut="showImage(this,'../../images/queryblank.gif')" >查
询 <img style="cursor:hand" src="../../images/printviewblank.gif" name="pre_print" value="打印预览" onClick = "view()" onMouseOver="showImage(this,'../../images/printviewcolor.gif')" onMouseOut="showImage(this,'../../images/printviewblank.gif')" >打印预览
<img src="../../images/printblank.gif" name="print" width="28" height="22" style="cursor:hand" onClick = "doprint()" onMouseOver="showImage(this,'../../images/printcolor.gif')" onMouseOut="showImage(this,'../../images/printblank.gif')" value="打 印" >打
印</div></td>
<td align="left" > </td>
</tr>
<tr>
<td height="28" colspan="2" align="center" ><font size="3">北方群星销售报表</font></td>
<td align="left" > </td>
</tr>
<tr>
<td width="294" height="26" align="left" >统计时间:
<%
if(sBeginDate.equals("") && sEndDate.equals("")){
%>
<input type="text" name="date1" size="24" class="bottomline" value="从<%=dateDealWith.getCurrentDate()%>到<%=dateDealWith.getCurrentDate()%>">
<%
}else{
%>
<input type="text" name="date1" size="24" class="bottomline" value="从<%=sBeginDate%>到<%=sEndDate%>">
<%
}
%>
</td>
<td width="260" align="left" ><div align="right">制作时间:
<input type="text" name="date2" size="10" class="bottomline" value="<%=dateDealWith.getCurrentDate()%>">
</div></td>
<td width="128" align="left" > </td>
</tr>
<tr>
<td height="98" colspan="2"> <table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="e3e1e2">
<tr>
<td bgcolor="336799"><div align="center"><font color="#FFFFFF" >业务类型</font></div></td>
<td height="23" bgcolor="336799"> <div align="center"><font color="#FFFFFF">数量(辆)</font></div></td>
</tr>
<tr>
<td bgcolor="F4F3DF"><div align="center">整车</div></td>
<%
//统计整车销售数量
int iAllSaleNum=saleReport.allSaleStatistics(sBeginDate,sEndDate,sCarType,sDepartment,sOperater);
if(iAllSaleNum>0){
%>
<td height="22" bgcolor="F4F3DF" align="center"><a href="allSaleReportList.jsp?sBeginDate=<%=sBeginDate%>&sEndDate=<%=sEndDate%>&sCarType=<%=sCarType%>&sDepartment=<%=sDepartment%>&sOperater=<%=sOperater%>"><font color="#000000" ><%=iAllSaleNum%></font></a></td>
<%
}else{
%>
<td height="22" bgcolor="F4F3DF" align="center"><font color="#000000" ><%=iAllSaleNum%></font></td>
<%
}
%>
</tr>
<tr>
<td bgcolor="FFFFF3"><div align="center">分期车</div></td>
<%
//统计分期车销售数量
int iDivConctractCarSaleNum=saleReport.divConctractCarSaleStatistics(sBeginDate,sEndDate,sCarType,sDepartment,sOperater);
if(iDivConctractCarSaleNum>0){
%>
<td height="24" bgcolor="FFFFF3" align="center"><a href="divConctractCarSaleList.jsp?sBeginDate=<%=sBeginDate%>&sEndDate=<%=sEndDate%>&sCarType=<%=sCarType%>&sDepartment=<%=sDepartment%>&sOperater=<%=sOperater%>"><font color="#000000" ><%=iDivConctractCarSaleNum%></font></a></td>
<%
}else{
%>
<td height="24" bgcolor="FFFFF3"> <div align="center"><font color="#000000" ><%=iDivConctractCarSaleNum%></font></div></td>
<%
}
%>
</tr>
<tr bgcolor="#F4F3DF">
<td><div align="center"><font color="#000000">合计</font></div></td>
<td height="23"> <div align="center"><%=iAllSaleNum+iDivConctractCarSaleNum%></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="27"> </td>
<td height="27"><div align="right">制作人:
<input type="text" size="10" name="makePerson" value="XXX" class="bottomline">
</div></td>
</tr>
</table>
<input type="hidden" name="beginDate" value="<%=sBeginDate%>">
<input type="hidden" name="endDate" value="<%=sEndDate%>">
<input type="hidden" name="department" value="<%=sDepartment%>">
<input type="hidden" name="operater" value="<%=sOperater%>">
<input type="hidden" name="carType" value="<%=sCarType%>">
</form>
</body>
</html>
======================================================================
说明:
1.在打印的页面里首先要引入的jsp(也可以是其它的格式:text等):printSet.jsp
2.调用printSet.jsp的view()方法可以打印览,调用doprint()可以打印,在打印印览时可以设置纸张大小和横打还是竖打,其实调用的就是window中的打印印览。
3.如果在打印中不想打印某一部分,可以隐藏。采用printSet.jsp中的style格式:
<div class="noprint">
要隐藏的内容
</div>
#19
例子有点乱,看不太明白
#20
请教:
例子好像都是在一个页面里,如果同一个表格的样式,但是对应3条不同的记录,这样就要在三张A4上打印3张不同内容的表格。这样怎么控制呢?
例子好像都是在一个页面里,如果同一个表格的样式,但是对应3条不同的记录,这样就要在三张A4上打印3张不同内容的表格。这样怎么控制呢?
#21
123
#22
mark
#23
感谢:flymoods(放飞心情)
帮我一个大忙了
支持
帮我一个大忙了
支持
#1
可以使用ie进行打印
<style>
@media print {
.ipt {display:none}
}
</style>
<object ID="WebBrowser1" WIDTH="0" HEIGHT="0"
CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<input type=button class="ipt" name=print value="打印" onclick="WebBrowser1.ExecWB(6,1)">
<input type=button class="ipt" name=print value="打印预览" onclick="WebBrowser1.ExecWB(7,1)">
<input type=button class="ipt" name=print value="页面设置" onclick="WebBrowser1.ExecWB(8,1)">
可以研究一下css控制,微软的网站上有讲到.
<style>
@media print {
.ipt {display:none}
}
</style>
<object ID="WebBrowser1" WIDTH="0" HEIGHT="0"
CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<input type=button class="ipt" name=print value="打印" onclick="WebBrowser1.ExecWB(6,1)">
<input type=button class="ipt" name=print value="打印预览" onclick="WebBrowser1.ExecWB(7,1)">
<input type=button class="ipt" name=print value="页面设置" onclick="WebBrowser1.ExecWB(8,1)">
可以研究一下css控制,微软的网站上有讲到.
#2
商业化的可选一些打印控件,不过大部分要钱的
免费的不太好用
免费的不太好用
#3
可以生成word文件直接在IE里面调入word,操作就是word的事了!
#4
利用ie只能打印当前显示出来的页,不能打印记录集中的其它页(通过"翻页"按钮在网页上显示出来),而用word或excel又要求用户必须安装有office.有没有其它方法呀?
#5
看看,没试过:
http://expert.csdn.net/Expert/topic/1978/1978459.xml?temp=4.755801E-02
http://expert.csdn.net/Expert/topic/1978/1978459.xml?temp=4.755801E-02
#6
看看,没试过:
http://expert.csdn.net/Expert/topic/1978/1978459.xml?temp=4.755801E-02
http://expert.csdn.net/Expert/topic/1978/1978459.xml?temp=4.755801E-02
#7
我搞错了!我也是到1号才放假的!!不好意思!你放心的来吧!不用担心的!
我下班了!!大脑中一篇空白!没有能量了!真的没有!
我下班了!!大脑中一篇空白!没有能量了!真的没有!
#8
"http://expert.csdn.net/Expert/topic/1978/1978459.xml?temp=4.755801E-02"中的介绍的文章只适合html与服务器脚本混合生成的Web打印,而我现在的前端是通过servlet类生成纯html后返回的,故难以解决分页打印及给每页加上同一标题这一问题
#9
生成PDF文件打印
#10
to usa112233
如何生成pdf文件?
如何生成pdf文件?
#11
<style>
div.page { page-break-after: always }
@media print{
select {display:none}
.noprint {display:none}
}
</style>
<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 language=javascript>
function window.onload()
{
factory.printing.header = "&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
}
function view(){
factory.printing.Preview();
}
function doprint(){
window.print();
}
</script>
div.page { page-break-after: always }
@media print{
select {display:none}
.noprint {display:none}
}
</style>
<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 language=javascript>
function window.onload()
{
factory.printing.header = "&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
}
function view(){
factory.printing.Preview();
}
function doprint(){
window.print();
}
</script>
#12
to flymoods(放飞心情)
免费的ScriptX.cab组件不能通过Javascript来控制"纸张类型"及"打印方向"
免费的ScriptX.cab组件不能通过Javascript来控制"纸张类型"及"打印方向"
#13
可以呀,我当前用的就可以,可以设置大小和打印方向,还可以设置表头和表尾!
#14
还有,我用的这个打印的东西需要用IE6!如果必要的话我可以给你一个列子。
#15
to flymoods(放飞心情)
我的IE也是V6,请给一个比较详细的例子,谢!
我的IE也是V6,请给一个比较详细的例子,谢!
#16
用商业的如,方成的报表,就不错,用IE的太不灵活,
#17
那得要银子呀,呵呵!
#18
例子来了:
========================================
printSet.jsp
<style>
div.page { page-break-after: always }
@media print{
select {display:none}
.noprint {display:none}
}
</style>
<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 language=javascript>
function window.onload()
{
factory.printing.header = "&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
}
function view(){
factory.printing.Preview();
}
function doprint(){
window.print();
}
</script>
=============================================
下面是具体用打印的jsp
<%@ page contentType="text/html; charset=gb2312" %>
<jsp:useBean id="saleReport" scope="page" class="com.eachtand.qunxing.report.SaleReport" />
<jsp:useBean id="dateDealWith" scope="page" class="com.eachtand.common.util.DateDealWith" />
<%
//引进printSet.jsp文件
%>
<%@include file = "../common/printSet.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../../css/general.css" rel="stylesheet" type="text/css">
<script src="../../js/Mouse.js"></script>
<script language=javaScript >
//弹出模式窗口,查询界面
var k;
var s = new Object();
function saleSearch(){
k = showModalDialog('saleSearch.jsp',s,'dialogHeight:210px;dialogWidth:600px;status:no;help:no');
if(k!=null){
form1.beginDate.value=k.beginDate;
form1.endDate.value=k.endDate;
form1.department.value=k.department;
form1.operater.value=k.operater;
form1.carType.value=k.carType;
form1.submit();
}
}
</script>
</head>
<%
String sBeginDate=request.getParameter("beginDate");//得到查询条件开始时间
if(sBeginDate==null && sBeginDate==null)
sBeginDate="";
String sEndDate=request.getParameter("endDate");//得到查询条件结束时间
if(sEndDate==null)
sEndDate="";
String sDepartment=request.getParameter("department");//得到查询条件部门
if(sDepartment==null)
sDepartment="";
String sOperater=request.getParameter("operater");//得到查询条件业务员
if(sOperater==null)
sOperater="";
String sCarType=request.getParameter("carType") ;//得到查询条件汽车类型
if(sCarType==null)
sCarType="";
%>
<body bgcolor="EAF1FB" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div class="toptable"><spacer type=block height=1></div>
<form name="form1" method="post">
<table width="90%" height="214" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="left" class="tableTitle"> </td>
<td align="center" >
<div class="noprint">
<img style="cursor:hand" src="../../images/queryblank.gif" onClick="saleSearch()" onMouseOver="showImage(this,'../../images/querycolor.gif')" onMouseOut="showImage(this,'../../images/queryblank.gif')" >查
询 <img style="cursor:hand" src="../../images/printviewblank.gif" name="pre_print" value="打印预览" onClick = "view()" onMouseOver="showImage(this,'../../images/printviewcolor.gif')" onMouseOut="showImage(this,'../../images/printviewblank.gif')" >打印预览
<img src="../../images/printblank.gif" name="print" width="28" height="22" style="cursor:hand" onClick = "doprint()" onMouseOver="showImage(this,'../../images/printcolor.gif')" onMouseOut="showImage(this,'../../images/printblank.gif')" value="打 印" >打
印</div></td>
<td align="left" > </td>
</tr>
<tr>
<td height="28" colspan="2" align="center" ><font size="3">北方群星销售报表</font></td>
<td align="left" > </td>
</tr>
<tr>
<td width="294" height="26" align="left" >统计时间:
<%
if(sBeginDate.equals("") && sEndDate.equals("")){
%>
<input type="text" name="date1" size="24" class="bottomline" value="从<%=dateDealWith.getCurrentDate()%>到<%=dateDealWith.getCurrentDate()%>">
<%
}else{
%>
<input type="text" name="date1" size="24" class="bottomline" value="从<%=sBeginDate%>到<%=sEndDate%>">
<%
}
%>
</td>
<td width="260" align="left" ><div align="right">制作时间:
<input type="text" name="date2" size="10" class="bottomline" value="<%=dateDealWith.getCurrentDate()%>">
</div></td>
<td width="128" align="left" > </td>
</tr>
<tr>
<td height="98" colspan="2"> <table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="e3e1e2">
<tr>
<td bgcolor="336799"><div align="center"><font color="#FFFFFF" >业务类型</font></div></td>
<td height="23" bgcolor="336799"> <div align="center"><font color="#FFFFFF">数量(辆)</font></div></td>
</tr>
<tr>
<td bgcolor="F4F3DF"><div align="center">整车</div></td>
<%
//统计整车销售数量
int iAllSaleNum=saleReport.allSaleStatistics(sBeginDate,sEndDate,sCarType,sDepartment,sOperater);
if(iAllSaleNum>0){
%>
<td height="22" bgcolor="F4F3DF" align="center"><a href="allSaleReportList.jsp?sBeginDate=<%=sBeginDate%>&sEndDate=<%=sEndDate%>&sCarType=<%=sCarType%>&sDepartment=<%=sDepartment%>&sOperater=<%=sOperater%>"><font color="#000000" ><%=iAllSaleNum%></font></a></td>
<%
}else{
%>
<td height="22" bgcolor="F4F3DF" align="center"><font color="#000000" ><%=iAllSaleNum%></font></td>
<%
}
%>
</tr>
<tr>
<td bgcolor="FFFFF3"><div align="center">分期车</div></td>
<%
//统计分期车销售数量
int iDivConctractCarSaleNum=saleReport.divConctractCarSaleStatistics(sBeginDate,sEndDate,sCarType,sDepartment,sOperater);
if(iDivConctractCarSaleNum>0){
%>
<td height="24" bgcolor="FFFFF3" align="center"><a href="divConctractCarSaleList.jsp?sBeginDate=<%=sBeginDate%>&sEndDate=<%=sEndDate%>&sCarType=<%=sCarType%>&sDepartment=<%=sDepartment%>&sOperater=<%=sOperater%>"><font color="#000000" ><%=iDivConctractCarSaleNum%></font></a></td>
<%
}else{
%>
<td height="24" bgcolor="FFFFF3"> <div align="center"><font color="#000000" ><%=iDivConctractCarSaleNum%></font></div></td>
<%
}
%>
</tr>
<tr bgcolor="#F4F3DF">
<td><div align="center"><font color="#000000">合计</font></div></td>
<td height="23"> <div align="center"><%=iAllSaleNum+iDivConctractCarSaleNum%></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="27"> </td>
<td height="27"><div align="right">制作人:
<input type="text" size="10" name="makePerson" value="XXX" class="bottomline">
</div></td>
</tr>
</table>
<input type="hidden" name="beginDate" value="<%=sBeginDate%>">
<input type="hidden" name="endDate" value="<%=sEndDate%>">
<input type="hidden" name="department" value="<%=sDepartment%>">
<input type="hidden" name="operater" value="<%=sOperater%>">
<input type="hidden" name="carType" value="<%=sCarType%>">
</form>
</body>
</html>
======================================================================
说明:
1.在打印的页面里首先要引入的jsp(也可以是其它的格式:text等):printSet.jsp
2.调用printSet.jsp的view()方法可以打印览,调用doprint()可以打印,在打印印览时可以设置纸张大小和横打还是竖打,其实调用的就是window中的打印印览。
3.如果在打印中不想打印某一部分,可以隐藏。采用printSet.jsp中的style格式:
<div class="noprint">
要隐藏的内容
</div>
========================================
printSet.jsp
<style>
div.page { page-break-after: always }
@media print{
select {display:none}
.noprint {display:none}
}
</style>
<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 language=javascript>
function window.onload()
{
factory.printing.header = "&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
}
function view(){
factory.printing.Preview();
}
function doprint(){
window.print();
}
</script>
=============================================
下面是具体用打印的jsp
<%@ page contentType="text/html; charset=gb2312" %>
<jsp:useBean id="saleReport" scope="page" class="com.eachtand.qunxing.report.SaleReport" />
<jsp:useBean id="dateDealWith" scope="page" class="com.eachtand.common.util.DateDealWith" />
<%
//引进printSet.jsp文件
%>
<%@include file = "../common/printSet.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../../css/general.css" rel="stylesheet" type="text/css">
<script src="../../js/Mouse.js"></script>
<script language=javaScript >
//弹出模式窗口,查询界面
var k;
var s = new Object();
function saleSearch(){
k = showModalDialog('saleSearch.jsp',s,'dialogHeight:210px;dialogWidth:600px;status:no;help:no');
if(k!=null){
form1.beginDate.value=k.beginDate;
form1.endDate.value=k.endDate;
form1.department.value=k.department;
form1.operater.value=k.operater;
form1.carType.value=k.carType;
form1.submit();
}
}
</script>
</head>
<%
String sBeginDate=request.getParameter("beginDate");//得到查询条件开始时间
if(sBeginDate==null && sBeginDate==null)
sBeginDate="";
String sEndDate=request.getParameter("endDate");//得到查询条件结束时间
if(sEndDate==null)
sEndDate="";
String sDepartment=request.getParameter("department");//得到查询条件部门
if(sDepartment==null)
sDepartment="";
String sOperater=request.getParameter("operater");//得到查询条件业务员
if(sOperater==null)
sOperater="";
String sCarType=request.getParameter("carType") ;//得到查询条件汽车类型
if(sCarType==null)
sCarType="";
%>
<body bgcolor="EAF1FB" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div class="toptable"><spacer type=block height=1></div>
<form name="form1" method="post">
<table width="90%" height="214" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="30" align="left" class="tableTitle"> </td>
<td align="center" >
<div class="noprint">
<img style="cursor:hand" src="../../images/queryblank.gif" onClick="saleSearch()" onMouseOver="showImage(this,'../../images/querycolor.gif')" onMouseOut="showImage(this,'../../images/queryblank.gif')" >查
询 <img style="cursor:hand" src="../../images/printviewblank.gif" name="pre_print" value="打印预览" onClick = "view()" onMouseOver="showImage(this,'../../images/printviewcolor.gif')" onMouseOut="showImage(this,'../../images/printviewblank.gif')" >打印预览
<img src="../../images/printblank.gif" name="print" width="28" height="22" style="cursor:hand" onClick = "doprint()" onMouseOver="showImage(this,'../../images/printcolor.gif')" onMouseOut="showImage(this,'../../images/printblank.gif')" value="打 印" >打
印</div></td>
<td align="left" > </td>
</tr>
<tr>
<td height="28" colspan="2" align="center" ><font size="3">北方群星销售报表</font></td>
<td align="left" > </td>
</tr>
<tr>
<td width="294" height="26" align="left" >统计时间:
<%
if(sBeginDate.equals("") && sEndDate.equals("")){
%>
<input type="text" name="date1" size="24" class="bottomline" value="从<%=dateDealWith.getCurrentDate()%>到<%=dateDealWith.getCurrentDate()%>">
<%
}else{
%>
<input type="text" name="date1" size="24" class="bottomline" value="从<%=sBeginDate%>到<%=sEndDate%>">
<%
}
%>
</td>
<td width="260" align="left" ><div align="right">制作时间:
<input type="text" name="date2" size="10" class="bottomline" value="<%=dateDealWith.getCurrentDate()%>">
</div></td>
<td width="128" align="left" > </td>
</tr>
<tr>
<td height="98" colspan="2"> <table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="e3e1e2">
<tr>
<td bgcolor="336799"><div align="center"><font color="#FFFFFF" >业务类型</font></div></td>
<td height="23" bgcolor="336799"> <div align="center"><font color="#FFFFFF">数量(辆)</font></div></td>
</tr>
<tr>
<td bgcolor="F4F3DF"><div align="center">整车</div></td>
<%
//统计整车销售数量
int iAllSaleNum=saleReport.allSaleStatistics(sBeginDate,sEndDate,sCarType,sDepartment,sOperater);
if(iAllSaleNum>0){
%>
<td height="22" bgcolor="F4F3DF" align="center"><a href="allSaleReportList.jsp?sBeginDate=<%=sBeginDate%>&sEndDate=<%=sEndDate%>&sCarType=<%=sCarType%>&sDepartment=<%=sDepartment%>&sOperater=<%=sOperater%>"><font color="#000000" ><%=iAllSaleNum%></font></a></td>
<%
}else{
%>
<td height="22" bgcolor="F4F3DF" align="center"><font color="#000000" ><%=iAllSaleNum%></font></td>
<%
}
%>
</tr>
<tr>
<td bgcolor="FFFFF3"><div align="center">分期车</div></td>
<%
//统计分期车销售数量
int iDivConctractCarSaleNum=saleReport.divConctractCarSaleStatistics(sBeginDate,sEndDate,sCarType,sDepartment,sOperater);
if(iDivConctractCarSaleNum>0){
%>
<td height="24" bgcolor="FFFFF3" align="center"><a href="divConctractCarSaleList.jsp?sBeginDate=<%=sBeginDate%>&sEndDate=<%=sEndDate%>&sCarType=<%=sCarType%>&sDepartment=<%=sDepartment%>&sOperater=<%=sOperater%>"><font color="#000000" ><%=iDivConctractCarSaleNum%></font></a></td>
<%
}else{
%>
<td height="24" bgcolor="FFFFF3"> <div align="center"><font color="#000000" ><%=iDivConctractCarSaleNum%></font></div></td>
<%
}
%>
</tr>
<tr bgcolor="#F4F3DF">
<td><div align="center"><font color="#000000">合计</font></div></td>
<td height="23"> <div align="center"><%=iAllSaleNum+iDivConctractCarSaleNum%></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="27"> </td>
<td height="27"><div align="right">制作人:
<input type="text" size="10" name="makePerson" value="XXX" class="bottomline">
</div></td>
</tr>
</table>
<input type="hidden" name="beginDate" value="<%=sBeginDate%>">
<input type="hidden" name="endDate" value="<%=sEndDate%>">
<input type="hidden" name="department" value="<%=sDepartment%>">
<input type="hidden" name="operater" value="<%=sOperater%>">
<input type="hidden" name="carType" value="<%=sCarType%>">
</form>
</body>
</html>
======================================================================
说明:
1.在打印的页面里首先要引入的jsp(也可以是其它的格式:text等):printSet.jsp
2.调用printSet.jsp的view()方法可以打印览,调用doprint()可以打印,在打印印览时可以设置纸张大小和横打还是竖打,其实调用的就是window中的打印印览。
3.如果在打印中不想打印某一部分,可以隐藏。采用printSet.jsp中的style格式:
<div class="noprint">
要隐藏的内容
</div>
#19
例子有点乱,看不太明白
#20
请教:
例子好像都是在一个页面里,如果同一个表格的样式,但是对应3条不同的记录,这样就要在三张A4上打印3张不同内容的表格。这样怎么控制呢?
例子好像都是在一个页面里,如果同一个表格的样式,但是对应3条不同的记录,这样就要在三张A4上打印3张不同内容的表格。这样怎么控制呢?
#21
123
#22
mark
#23
感谢:flymoods(放飞心情)
帮我一个大忙了
支持
帮我一个大忙了
支持