Implementing report Printing in ASP with Xml+vbs

Source: Internet
Author: User
Tags date object end sql version
xml| Printing

First, the preface
ASP is widely used in e-commerce, and there are some problems in report processing. This article describes the use of ASP
I write the report Server page script interpreter to achieve the display of reports, printing.
Ii. preparatory work
(1) Install visual Reprort design software
Visual reports design is a free Report Designer I write, the release of the program only needs
You can install a control.
Want the Netizen can go to http://go.163.com/reportpro/ to download
(2) Design report
You can generate a script for a report through the visual interface of visual reports: MXB.RSP.
Third, the realization of the report of the printing, display
The following is the document that was invoked:
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
%>
<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>
Report script generated using visual MXB.RSP:
<?xml version= "1.0" encoding= "GB2312"?>
<! DOCTYPE "PRINT_REPORT.DTD" >
<report name= "Report" >
<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= ">"
<text name= "Vfptext" top= "4" left= "the" width= "" height= "5" font_name= "Song Body" font_size= "" font_weight= "" Font_ " italic= "0" font_underline= "0" >
Schedule of Achievements
</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= "" width= "6" height= "3" font_name= "Arial" font_size= "9" font_weight= "he" font_ italic= "0" font_underline= "0" >
Name
</text>
<text name= "Vfptext" top= "2" left= "" width= "6" height= "3" font_name= "Song Body" font_size= "9" font_weight= "he" font_ italic= "0" font_underline= "0" >
Chinese
</text>
<text name= "Vfptext" top= "2" left= "6" width= "3" height= "Song Body" font_name= "9" font_size= "he" font_weight= italic= "0" font_underline= "0" >
Mathematical
</text>
<text name= "Vfptext" top= "2" left= "" width= "6" height= "3" font_name= "Song Body" font_size= "9" font_weight= "Font_" italic= "0" font_underline= "0" >
English
</text>
<text name= "Vfptext" top= "2" left= "162" width= "6" height= "3" font_name= "Song Body" font_size= "9" font_weight= "he" font_ italic= "0" font_underline= "0" >
Total
</text>
<text name= "Vfptext" top= "2" left= "130" width= "6" height= "3" font_name= "Song Body" font_size= "9" font_weight= "he" font_ italic= "0" font_underline= "0" >
Average
</text>
</page_head>
<page_body height= "8" >
<text name= "Vfptext" top= "2" left= "width=" "height=" "4" font_name= "Song Body" font_size= "9" font_weight= "Font_" italic= "0" font_underline= "0" >
<report_script>
Report.write CStr (RS ("XM"))
</report_script>
</text>
<text name= "Vfptext" top= "2" left= "" width= "" height= "4" font_name= "Song Body" font_size= "9" font_weight= "Font_" italic= "0" font_underline= "0" >
<report_script>
Report.write CStr (rs ("yw"))
</report_script>
</text>
<text name= "Vfptext" top= "2" left= "" "Width=" height= "4" font_name= "Song Body" font_size= "9" font_weight= "Font_" italic= "0" font_underline= "0" >
<report_script>
Report.write CStr (RS ("SX"))
</report_script>
</text>
<text name= "Vfptext" top= "2" left= "9" width= "height=" 4 "font_name=" "Song Body" font_size= "the", font_weight= "" "Font_" italic= "0" font_underline= "0" >
<report_script>
Report.write CStr (rs ("yy"))
</report_script>
</text>
<text name= "Vfptext" top= "2" left= "130" width= "height=" "4" font_name= "Song Body" font_size= "9" font_weight= "" 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= "height=" "4" font_name= "Song Body" font_size= "9" font_weight= "" 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= "" width= "" height= "3" font_name= "Song Body" font_size= "9" font_weight= "Font_" italic= "0" font_underline= "0" >
<report_script>
Report.write "Print Date:" +formatdatetime (Date (), 1)
</report_script>
</text>
<text name= "Vfptext" top= "2" left= "137" width= "height=" "3" Font_name= "Song Body" font_size= "9" font_weight= "Font_" italic= "0" font_underline= "0" >
Total%pages% page, page%page%
</text>
<line name= "Vfpline" top= "0" left= "8" width= "178" height= "0" weight= "131072" >
</line>
</page_foot>
<report_script>
Do as not rs.eof
Page_body ()
Rs.movenext
Loop
Rs.close
Set rs=nothing
Con.close
Set con=nothing
</report_script>
</report>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.