A new way to print Excel tables in an ASP program

Source: Internet
Author: User

A new way to print Excel reports in an ASP program
 
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! &NBSP
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& "") &NBSP
Conn. Open connstr 
Set Rsd=server.createobject ("Adodb.recordset")  
str= "select * from cjb00" &NBSP;
Rsd.open str,conn 
ii=1 
do, not rsd.eof and ii<11 
%> 
<% Response.Write "Xlsheet1.cells (" &ii+4& ", 2). value="%> "<%=RSD (" name ")%>" &NBSP;
<% Response.Write "Xlsheet1.cells" ("&ii+4&", 3). value= "%>" <%=RSD ("School Number")%> "&NBSP;
<% 
RSD.MOVENEXT&NBSP
ii=ii+1 
loop 
rsd.close 
set rsd=nothing 
%> 
XlSheet1.Application.Visible = true 
End function 
//***************** This program is provided by the Mars Studio ************  
<% 
Response.Write "</script>"  
%>


<body> 
<center> 
<p>&nbsp;</p> &NBSP
<form name= "FMP" method= "POST" action= "" >&NBSP;
<% 
db= "Zhk.mdb" &NBSP;
Set conn = Server.CreateObject ("ADODB.") Connection ")  
connstr=" Provider=Microsoft.Jet.OLEDB.4.0;Data source= "& Server.MapPath (" "&db& "") &NBSP
Conn. Open connstr 
Set Rsd=server.createobject ("Adodb.recordset")  
str= "select * from cjb00" &NBSP;
Rsd.open str,conn 
%> 
<table width= "396" height= "" border= "1" bordercolor= "#00FF00" bgcolor =LIGHTYELLOW>&NBSP
<tr bgcolor=deepskyblue> 
<th><b> name </b></th> &NBSP
<th><b> </b></th> 
</tr> 
<% 
Do RSD.EOF&NBSP
%> 
<tr ALIGN=CENTER>&NBSP
<td> <%=rsd ("name")%> 
</td> 
<td> <%=rsd ("School Number" )%> 
</td> 
</tr> 
<% 
RSD. MOVENEXT&NBSP
loop 
%> 
<% rsd.close 
set rsd=nothing 
Conn.close &NBSP
Set cnn=nothing%> 
</table> 
<p> 
<input name= "Submit2" type= "Button" onclick= "Ccprint ()" ondblclick= "Ccprint ()" value= "print" >&NBSP;
<br> 
</p> 
</form> 
</center> 
</body> 

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.