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= "<%=RSD (" name ")%>" >
<%=RSD ("name")%>
</td>
<td>
<input name= "<%=" M "&n%>" type= "hidden" value= "<%=RSD (" School Number ")%>" >
<%=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