| 搜索频道 | 源码下载 | 站长代码论坛 | 文章分类 | 最新专题 | 源码交易 | 加入收藏
首页|资讯|图形图像|网站开发|程序设计|数据库|多媒体|机械电子|办公系列|路由技术|原理|应用|考试|系统
文章搜索:
 您的位置:首页网站开发XML → 使用XML+VBS技术在ASP中实现报表的打印
使用XML+VBS技术在ASP中实现报表的打印

日期:2006-7-12 11:45:45 人气:     [ ]
一、前言
ASP在电子商务上应用广泛,报表的处理又有一些麻烦。本文介绍了在ASP中利用
本人写的Report Server Page脚本解释器实现报表的显示、打印。
二、准备工作
(1)安装Visual Reprort Design软件
Visual Report Design是本人写的一个免费的报表设计器,程序的发行只需要
安装一个控件即可。
想要的网友可以到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_weight='100' font_italic='0' font_underline='0' >

<report_script>

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

</report_script>

</text>

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

<report_script>

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

</report_script>

</text>

<text name='vfptext' top='2' left='130' 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")+rs("sx")+rs("yy"))/3)

</report_script>

</text>

<text name='vfptext' top='2' left='162' 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")+rs("sx")+rs("yy"))

</report_script>

</text>

</page_body>

<page_foot height='7'>

<text name='vfptext' top='2' left='12' width='13' height='3' font_name='宋体' font_size='9' font_weight='100' font_italic='0' font_underline='0' >

<report_script>

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

</report_script>

</text>

<text name='vfptext' top='2' left='137' width='50' height='3' font_name='宋体' font_size='9' font_weight='100' font_italic='0' font_underline='0' >

共%Pages%页,第%Page%页

</text>

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

</line>

</page_foot>

<report_script>

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

</report_script>

</report>

四、其它信息
这是本人第一个开发工具,做得不好请指教
详细情况可以看:http://go.163.com/reportpro/
关于在ASP下使用的详细例子可以看c:\demo\asp/目录

出处:本站原创 作者:zzcode
 相关文章
·利用oleDB对象,将数据库中全部表转换成XML文件
·XML 使用NodeList对象
·简析JAVA的XML编程
·XML使用其它方法来存取元素
·把HTML表单提交的数据转化成XML文件
·存取XML的属性
·XML与其相关技术
·浏览整个XML文件
·XML入门精解之结构与语法
·用ASP、VB和XML建立互联网应用程序
 相关软件
·ASP+XML 精美留言本
·E路XML留言本(Elook XML GuestBook) v1.0 无组件..
·爱上网XML自助链接
·JOB571.COM即插即用自助友情链接(XML版)
·XML 编程从入门到精通(PDF)
·厦门普工招聘网XML留言簿
·XMLBlueprint XML Editor v3.6
·Altova XMLSpy 2005 SP3 企业特别版
·Ektron eWebEditPro+XML v4.2.0.11 特别版
·XMLwriter v2.5 特别版
 

 热点文章

·XML新增批注、处理指令..
·用ASP、VB和XML建立互..
·XML 中的常见问题
·带可选项、带图片的无..
·将XML文件链接至HTML网..
·用XML实现国家、省的动..
·构造未来Web页面的工具..
·简单的XML留言板
·web.xml中的 security..
·使用xmlhttp 实现多文..
·XML与其相关技术
·简析JAVA的XML编程
·利用XML不离开页面刷新..
·SQL Server和XML的集成..
·修改大型 XML 文件的有..

 推荐文章

·端午非物质文化遗产登..
·动态网站Web开发PHP、..
·PS绘中秋佳节的一轮明..
·细谈网页优化和网站优..
·建站常识:如何使用FT..
·如何快速建造一个成功..
·ASP.NET 2.0 中的创建..
·ASP.NET2.0服务器控件..
·在ASP.NET应用中插入f..
·用Photoshop打造逼真立..
·Windows 2003搭建虚拟..
·站长必读:Web创业的1..
·如何测试机房的速度和..
·北京奥运体育图标发布..
·网络视频广告将身价百..