excel| Program | Print 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 Excel 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 ")
Open the worksheet!
Set xlbook = XlApp.Workbooks.Open ("C:\book1.xlt")
Set xlsheet1 = Xlbook.activesheet
<% 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
Ii=1
Do, not rsd.eof and ii<11
%>
<%response.write "Xlsheet1.cells (" &ii+4& ", 2). value="%> "<%=RSD (" name ")%>"
<%response.write "Xlsheet1.cells" ("&ii+4&", 3). value= "%>" <%=RSD ("School Number")%> "
<%
Rsd.movenext
Ii=ii+1
Loop
Rsd.close
Set rsd=nothing
%>
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>
<%
Do as not rsd.eof
%>
<tr align=center>
<td> <%=rsd ("name")%>
</td>
<td> <%=RSD ("School Number")%>
</td>
</tr>
<%
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 minimum or custom security level to enable the second item, because only in this way, ie can create an Excel object!
This procedure is provided by Andylee (MARS), if you have any comments please contact:
Email:andy2001p@hotmail.com
qq:16685104
tel:0595-2092139