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

來源:互聯網
上載者:User
列印 一、前言
ASP在電子商務上應用廣泛,報表的處理又有一些麻煩。本文介紹了在ASP中利用
本人寫的Report Server Page指令碼解譯器實現報表的顯示、列印。
二、準備工作
(1)安裝Visual Reprort Design軟體
Visual Report Design是本人寫的一個免費的報表設計師,程式的發行只需要
安裝一個60K的控制項即可。
想要的網友可以到http://go.163.com/reportpro/下載
(2)設計報表
通過Visual Report Design 的可視化介面可以產生報表的指令碼:mxb.rsp。
三、實現報表的列印、顯示
下面是調用的文檔:
printmx.asp
<%Option Explicit%>
<%
dim ReportName,ret
dim ReportAtl
dim name
set ReportAtl=Session("ReportAtl")
ReportName=Server.MapPath("mxb.rsp")
ret=reportatl.XMLToVBS(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
%>
<html>
<OBJECT id=reportatl classid="clsid:D3F064E5-F4C0-4C52-9E7F-263D96B7EA11" codebase="Report.cab#version=1,0,0,1">
</OBJECT>
<script language=vbscript>
dim ret
ret=reportatl.DoPrintReport("mxb.zcg")
if ret=-1 then
msgbox reportatl.ErrorMsg
end if
</script>
</html>

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

<?xml version='1.0' encoding='GB2312' ?>

<!DOCTYPE report SYSTEM 'print_report.dtd' >

<report name='報表'>

<report_script>

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

</report_script>

<report_head height='12'>

<text name='vfptext' top='4' left='76' width='26' height='5' font_name='宋體' font_size='14' font_weight='700' font_italic='0' font_underline='0' >

成績明細表

</text>

</report_head>

<page_head height='6'>

<line name='vfpline' top='0' left='9' width='178' height='0' weight='131072'>

</line>

<line name='vfpline' top='6' left='9' width='178' height='0' weight='131072'>

</line>

<text name='vfptext' top='2' left='18' width='6' height='3' font_name='宋體' font_size='9' font_weight='700' font_italic='0' font_underline='0' >

姓名

</text>

<text name='vfptext' top='2' left='46' width='6' height='3' font_name='宋體' font_size='9' font_weight='700' font_italic='0' font_underline='0' >

語文

</text>

<text name='vfptext' top='2' left='72' width='6' height='3' font_name='宋體' font_size='9' font_weight='700' font_italic='0' font_underline='0' >

數學

</text>

<text name='vfptext' top='2' left='99' width='6' height='3' font_name='宋體' font_size='9' font_weight='700' font_italic='0' font_underline='0' >

英語

</text>

<text name='vfptext' top='2' left='162' width='6' height='3' font_name='宋體' font_size='9' font_weight='700' font_italic='0' font_underline='0' >

合計

</text>

<text name='vfptext' top='2' left='130' width='6' height='3' font_name='宋體' font_size='9' font_weight='700' font_italic='0' font_underline='0' >

平均

</text>

</page_head>

<page_body height='8'>

<text name='vfptext' top='2' left='15' width='25' height='4' font_name='宋體' font_size='9' font_weight='100' font_italic='0' font_underline='0' >

<report_script>

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

</report_script>

</text>

<text name='vfptext' top='2' left='45' width='18' height='4' font_name='宋體' font_size='9' font_weight='100' font_italic='0' font_underline='0' >

<report_script>

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

</report_script>

</text>

<text name='vfptext' top='2' left='71' width='18' height='4' font_name='宋體' font_size='9' font_w



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.