How to print an Access report in an ASP program (a classic program without components)

Source: Internet
Author: User
access| Programs | printing | No components at present, B/S mode (browser/server mode) has become the preferred computing mode of the Enterprise network. Because of the particularity of B/S mode, the Excel report printing function which is relatively easy to realize under C/S is a difficult problem under B/S. I have written a program based on ASP program to print acess report. This procedure is characterized by no need for any components.
  
Print.asp
------------------------------------------------

<%
' Control scripting language
Response.Write "<script language=" & "VBScript" & ">"
%>
This procedure is provided by the Mars Studio (andy2001p@hotmail.com) ******************
All rights reserved FREE copy ********************************
function Ccprint ()
Set xlapp = CreateObject ("EXCEL. Application ")
Set xlbook = XlApp.Workbooks.Open ("C:\book1.xlt")
Set xlsheet1 = Xlbook.activesheet

<%
Ii=1
Do While ii<11
Response.Write "N" &ii& "=FMP.N" &ii& ". Value"
%>
Every other line!
<%response.write "Xlsheet1.cells (" &ii+4& ", 2). Value=n" &ii%>
Every other line!
<%response.write "M" &ii& "=fmp.m" &ii& ". Value"%>

Every other line!
<%response.write "Xlsheet1.cells (" &ii+4& ", 3). Value=m" &ii%>
Every other line!
<%
Ii=ii+1
Loop%>
XlSheet1.Application.Visible = True

End Function
This procedure is provided by the Mars Studio ******************
<%
Response.Write "</script>"
%>


<body>
<center>
<p> </p>
<form name= "FMP" method= "POST" action= "" >
<%
db= "Zhk.mdb"
Set conn = Server.CreateObject ("ADODB. Connection ")
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("&db&")
Conn. Open ConnStr
Set Rsd=server.createobject ("Adodb.recordset")
Str= "SELECT * from Cjb00"
Rsd.open Str,conn
%>
<table width= "396" height= "border=" "1" bordercolor= "#00FF00" bgcolor=lightyellow>
<tr bgcolor=deepskyblue>
<th><b> name </b></th>
<th><b> School Number </b></th>
</tr>
<%
N=1
Do as not rsd.eof
%>
<tr align=center>
<td>
<input name= "<%=" n "&n%>" type= "hidden" value= "&LT;%=RSD (" name ")%>" >
&LT;%=RSD ("name")%>
</td>
<td>
<input name= "<%=" M "&n%>" type= "hidden" value= "&LT;%=RSD (" School Number ")%>" >
&LT;%=RSD ("School Number")%>
</td>
</tr>
<%
M=m+1
N=n+1
Rsd. MoveNext
Loop
%>
<% Rsd.close
Set rsd=nothing
Conn.close
Set Cnn=nothing%>
</table>
<p>
<input name= "Submit2" type= "button" onclick= "Ccprint ()" ondblclick= "Ccprint ()" value= "Print" >
<br>
</p>
</form>
</center>
</body>
------------------------------------------------------------

After the program is written, you must build an Excel template file in the C-packing directory! In IE's security settings, the security level is set to the lowest or custom security level to enable the second item on it!
This procedure is provided by Andylee (MARS), if you have any comments please contact:
Email:andy2001p@hotmail.com
qq:16685104
tel:0595-2092139



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.