ASP環境下輕鬆實現報表的列印 (轉)

worldblog發表於2007-12-09
ASP環境下輕鬆實現報表的列印 (轉)[@more@]

 

一、前言
  在電子商務上應用廣泛,報表的處理又有一些麻煩。本文介紹了在ASP中利用
本人寫的Report Server Page指令碼直譯器實現報表的顯示、列印。
二、準備工作
  (1)Visual Reprort Design
  Visual Report Design是本人寫的一個免費的報表設計器,的發行只需要
  安裝一個60K的即可。
  想要的網友可以到
  (2)設計報表
  透過Visual Report Design 的視覺化介面可以生成報表的指令碼:mxb.rsp。
 三、實現報表的列印、顯示
  下面是的文件:
  printmx.asp
 
  dim ReportName,ret
 dim ReportAtl
 dim name
 set ReportAtl=Session("ReportAtl")
 ReportName=Server.MapPath("mxb.rsp")
 ret=reportatl.ToVBS(ReportName)
 if ret=-1 then
 response.write reportatl.ErrorMsg
 response.end
 end if

 ReportName=Server.MapPath("mxb.vbs")
 ret=reportatl.DoScript(ReportName)
 if ret=-1 then
 response.write reportatl.ErrorMsg
 set ReportAtl=nothing
 response.end
 end if
 set ReportAtl=nothing
  %>
 
  < id=reportatl classid="clsid:D3F064E5-F4C0-4C52-9E7F-263D96B7EA11" codebase="Report.cab#version=1,0,0,1">
 
 

<BR>&nbsp;dim ret<BR>&nbsp;ret=reportatl.DoPrintReport("mxb.zcg")<BR>&nbsp;if ret=-1 then<BR>&nbsp;msgbox reportatl.ErrorMsg<BR>&nbsp;end if<BR>&nbsp;

   
 
用Visual Report Design 產生的報表指令碼mxb.rsp:

 

dim rs,con,,lsh
 dim temp
 set con =CreateObject("ADO.Connection")
 con.ConnectionString = "DBQ=c:reportdemoaspreport.mdb;={ Access Driver (*.mdb)};"
 con.open
 Set rs =CreateObject("ADODB.Recordset")
 sql="  * FROM cj,student where cj.id=student.id "
 rs.open sql,con,1,3

成績明細表

姓名

語文

數學

英語

合計

平均

 Report.Write cstr(rs("xm"))

 Report.Write cstr(rs("yw"))

 Report.Write cstr(rs("sx"))

 Report.Write cstr(rs("yy"))

 Report.Write cstr((rs("yw")+rs("sx")+rs("yy"))/3)

 Report.Write cstr(rs("yw")+rs("sx")+rs("yy"))

 report.write "列印日期:"+formatdatetime(date(),1)

共%Pages%頁,第%Page%頁

do while not rs.eof
 page_body()
 rs.movenext
 l
 rs.close
 set rs=nothing
 con.close
 set con=nothing

 

四、其它資訊
  這是本人第一個開發工具,做得不好請指教
  詳細情況可以看:
  關於在ASP下使用的詳細例子可以看c:demoasp/目錄


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-990431/,如需轉載,請註明出處,否則將追究法律責任。

相關文章