关于ASP打印问题(200分)

T

toms_zy

Unregistered / Unconfirmed
GUEST, unregistred user!
请问在asp中如何实现类似DELPHI中的报表打印功能,听说有个水晶报表的组件,如何使用,在
何处下载,如能详细说明,万分感谢.
急!!!!!!
 
水晶报表是asp.net中才有吧,我想在asp中要么使用activex,要么发送到Excel中打印.
 
YoungSun,你能详细说说如何用EXCEL或者是ACTIVEX实现吗?谢谢.最好有例子,可以发到我的
信箱:zy@suzhou.cngb.com
 
发送到excel中,需要在asp中创建excel的对象,然后建新文档,插入内容.还是比较麻烦的,
CSDN上这篇文章你可以看一下,也许有帮助.
http://www.csdn.net/Develop/Article/15/15355.shtm
 
有个WEBPRINT控件,你可以试试.http://www.fcsoft.com.cn:8080/webprintsample/index.html
 
asp不好做,因为asp是服务端的
是否可以考虑做一个打印的ocx自动下载到客户端来进行打印
或者通过javascript调用dom对象通过打印html网页的方式来打印。
 
to Adnil:
您好,能发个例子或者详细说说吗?
 
我给大家一个例子,是用javascript脚本的,在body中最好不要家样式
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html>
<head>
<title>Untitleddo
cument</title>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
<link href="../css/style.css" rel="stylesheet" type="text/css">
<!--#include virtual="inc/dbcon.inc"-->
<!--#include virtual="connections/GetSQLcon.asp"-->
<!--#include virtual="inc/provide.inc"-->
<!--#include virtual="inc/islogined.inc"-->
<style type="text/css">
.table_up {
border-left:1 none #fffffe;
border-top:1 none #fffffe;
border-right:1 none #ebebeb;
border-bottom:1 none #ebebeb;
font-size:9pt;}
.but { border:1px buttonface solid;font-size:9pt;background:#C0C0C0 }
</style>
<script language="JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&amp;&amp;(parseInt(appVersion)==4)) {
do
cument.MM_pgW=innerWidth;
document.MM_pgH=innerHeight;
onresize=MM_reloadPage;
}}
else
if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</script>
<script langeuage="javascript">
var mlngTableWidth
var dblRate=1
var tablewidth = new Array()
var lngSize=0
function privew_onchange(current_value)
{
dblRate=parseInt(current_value)/100
lngSize=document.frm.cboZoom.selectedIndex
do
cument.recalc()
var o=document.all.tags("TABLE")
for (i=0;i<o.length;i++)
{
if (o.id!="toolbar" &amp;&amp;
o.id!="texterea")
{
if(tablewidth == null) tablewidth = o.width;
for (j=0;j<o.rows(0).cells.length;j++)
{
o.rows(0).cells(j).pixelWidth=parseInt(o.rows(0).cells(j).pixelWidth)*dblRate;
o.rows(0).cells(j).pixelHeight=parseInt(o.rows(0).cells(j).pixelHeight)*dblRate;
}
o.style.fontSize=10*dblRate+"pt" //arrFontSize[lngSize];
if(o.width!="")
{ o.width=tablewidth*dblRate}
}
}
do
cument.all.text.style.fontSize = 10*dblRate+"pt"
}
</script>
<link href="../../css/stylprnt.css" rel="stylesheet" type="text/css">
</head>
<%
if Request.QueryString("fangshi")=1 or Request.QueryString("fangshi")=2 then
leixing="督办"
else
leixing="承办"
end if
%>
<body>
<p align="center"> <span class="title1">
<%response.Write(Session("taxname"))%>
<strong>督查督办情况汇总表</strong></span></p>
<p align="left"><span class="texts"><strong>汇总类型</strong>:
<input name="Dtype" type="text" class="input0" id="Dtype" size="4" maxlength="10" value="<%=leixing%>">
   <strong> 查询区间</strong>:</span> <span class="texts">
<input name="ktime" type="text" class="input0" id="ktime" size="10" maxlength="15" value="<%=request("kstime")%>">
</span> —— <span class="texts">
<input name="jtime" type="text" class="input0" id="jtime" size="10" maxlength="15" value="<%=request("jstime")%>">
</span> </p>

<table width="100%" height="82" border="0" cellpadding="3" cellspacing="0" class="outertable">
<tr align="center" class="texts">
<td width="23%" rowspan="2"> 部门或单位名称</td>
<td width="13%" rowspan="2"> 立项数</td>
<td colspan="2"> 办结项数</td>
<td colspan="3"> 办理结果</td>
<td colspan="2"> 未办结项数</td>
</tr>
<tr class="texts">
<td width="8%" align="center"> 按期</td>
<td width="8%" align="center">延期</td>
<td width="9%" align="center" >满意</td>
<td width="9%" align="center" >一般</td>
<td width="9%" align="center" > 重办</td>
<td width="11%" align="center" >未逾期</td>
<td width="10%" align="center" >逾期</td>
</tr>
<%
'response.Write(session("taxid"))
set duchaR=server.CreateObject("ADODB.Recordset")
duchaR.PageSize =10
duchaR.CursorLocation = 3
duchaR.CursorType = 3
set duchaC=server.CreateObject("adodb.command")
duchaC.commandtype=4
set duchaC.activeconnection=GetSQLCon
duchaC.commandtext="cx_dcdb_hz"
duchaC("@ks")=request.QueryString("kstime")
duchaC("@jz")=request.QueryString("jstime")
duchaC("@id")=session("taxid")
duchaC("@fs")=request.QueryString("fangshi")
duchaR.open duchaC
duchaR.CacheSize = duchaR.PageSize
intPageCount = duchaR.PageCount
intRecordCount = duchaR.RecordCount
If Request.QueryString("page") = "" then
if len(Request.QueryString())>2 then
session("querystr")=Request.QueryString()
intPage = 1
else
intPage = Request.QueryString("page")
End If
If CInt(intPage) > CInt(intPageCount) then
intPage = intPageCount
If CInt(intPage) <= 0 then
intPage = 1
If intRecordCount > 0 then
duchaR.AbsolutePage = intPage
intStart = duchaR.AbsolutePosition
If CInt(intPage) = CInt(intPageCount) then
intFinish = intRecordCount
else
intFinish = intStart + (duchaR.PageSize - 1)
End if
End If
If intRecordCount > 0 then
j=1
For intRecord = 1 to duchaR.PageSize
%>
<tr class="texts" align="center" height="60">
<td width="8%" align="center"><%=duchaR(1)%></td>
<td width="8%" align="center"><a href="ducha12.asp?id=<%=duchaR(0)%>&amp;name=<%=duchaR(1)%>&amp;kstime=<%=request("kstime")%>&amp;jstime=<%=request("jstime")%>&amp;num=1&amp;fangshi=<%=request("fangshi")%>"><%=duchaR(2)%></a></td>
<td width="8%" align="center"><a href="ducha12.asp?id=<%=duchaR(0)%>&amp;name=<%=duchaR(1)%>&amp;kstime=<%=request("kstime")%>&amp;jstime=<%=request("jstime")%>&amp;num=2&amp;fangshi=<%=request("fangshi")%>"><%=duchaR(3)%></a></td>
<td width="8%" align="center"><a href="ducha12.asp?id=<%=duchaR(0)%>&amp;name=<%=duchaR(1)%>&amp;kstime=<%=request("kstime")%>&amp;jstime=<%=request("jstime")%>&amp;num=3&amp;fangshi=<%=request("fangshi")%>"><%=duchaR(4)%></a></td>
<td width="9%" align="center"><a href="ducha12.asp?id=<%=duchaR(0)%>&amp;name=<%=duchaR(1)%>&amp;kstime=<%=request("kstime")%>&amp;jstime=<%=request("jstime")%>&amp;num=4&amp;fangshi=<%=request("fangshi")%>"><%=duchaR(5)%></a></td>
<td width="9%" align="center"><a href="ducha12.asp?id=<%=duchaR(0)%>&amp;name=<%=duchaR(1)%>&amp;kstime=<%=request("kstime")%>&amp;jstime=<%=request("jstime")%>&amp;num=5&amp;fangshi=<%=request("fangshi")%>"><%=duchaR(6)%></a></td>
<td width="9%" align="center"><a href="ducha12.asp?id=<%=duchaR(0)%>&amp;name=<%=duchaR(1)%>&amp;kstime=<%=request("kstime")%>&amp;jstime=<%=request("jstime")%>&amp;num=6&amp;fangshi=<%=request("fangshi")%>"><%=duchaR(7)%></a></td>
<td width="11%" align="center"><a href="ducha12.asp?id=<%=duchaR(0)%>&amp;name=<%=duchaR(1)%>&amp;kstime=<%=request("kstime")%>&amp;jstime=<%=request("jstime")%>&amp;num=7&amp;fangshi=<%=request("fangshi")%>"><%=duchaR(8)%></a></td>
<td width="10%" align="center"><a href="ducha12.asp?id=<%=duchaR(0)%>&amp;name=<%=duchaR(1)%>&amp;kstime=<%=request("kstime")%>&amp;jstime=<%=request("jstime")%>&amp;num=8&amp;fangshi=<%=request("fangshi")%>"><%=duchaR(9)%></a></td>
</tr>
<%
j=j+1
duchaR.movenext
If duchaR.EOF then
Exit for
Next
end if
if duchaR.recordcount<1 then

response.Write("<tr class='texts'><td colspan=9> 没有结果</td></tr>")
else
response.Write("<tr class='texts'><td colspan=9 align='right'> 共发现记录 <b>"+cstr(intRecordCount)+" </b>项,共分 <b>"+cstr(intPageCount)+" </b>页显示,当前显示第 <b>"+cstr(intPage)+" </b>页。")
end if
If cInt(intPage) > 1 then
response.Write("<a href='?"+session("querystr")+"&amp;page="+cstr(intPage - 1)+"'></a>")
If cInt(intPage) < cInt(intPageCount) then
response.Write("<a href='?"+session("querystr")+"&amp;page="+cstr(intPage + 1)+"'></td></tr>")
set goal1=nothing
duchaR.close
set duchaR=nothing
%>
</table>
<p align="left" class="textxs">制表单位:
<input name="text17" type="text" class="input0" id="text17" size="20" value="<%=session("taxname")%>">
  制表人:
<input name="text18" type="text" class="input0" id="text18" size="10" value="<%=session("UserName")%>">
 制表日期:
<input name="text19" type="text" class="input0" id="text19" size="10" value="<%=cdate(date)%>">
</p>
</body>
</html>
 
水晶报表用8.0就可以了,还可以实现动态数据更新,不错的!!!
 
顶部