Recommended: ASP uses the phone number to generate the code for the picture Function: Generate the phone number on the page to image format. % Call Com_CreatValidCode(Request.QueryString(tel)) Public Sub Com_CreatValidCode(pTel) '----------禁止缓存Response.Expires = 0 Response.AddHeader Pragma,no-cache Response.AddHeader cache-ctro
ASP instance code directly exports the data in the database to the EXCEL spreadsheet.
<!--#include file=../conn.asp-->
<%
dim s,sql,filename,fs,myfile,x
Set fs = server.CreateObject(scripting.filesystemobject)
'--Suppose you want the generated EXCEL file to be stored as follows
filename = Server.MapPath(users.xls)
'--Delete the original EXCEL file if it exists
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
'--Create an EXCEL file
set myfile = fs.CreateTextFile(filename,true)
'Set rs = Server.CreateObject(ADODB.Recordset)
'--Follow the data you want to put into EXCEL from the database
'sql = select * from Tb_Execl order by id desc
'rs.Open sql,conn
StartTime = Request(StartTime)
EndTime = Request(EndTime)
StartEndTime = AddTime between #& StartTime & 00:00:00# and #& EndTime & 23:59:59#
strSql = select * from myeky_myusr
Set rstData =conn.execute(strSql)
if not rsstData.EOF and not rsstData.BOF then
dim trLine,responsestr
strLine=
For each x in rstData.fields
strLine = strLine & x.name & chr(9)
Next
'--Write the column name of the table to EXCEL first
myfile.writeline strLine
Do while Not rstData.EOF
strLine=
for each x in rsstData.Fields
strLine = strLine & x.value & chr(9)
next
myfile.writeline strLine
rsstData.MoveNext
loop
end if
Response.Write The EXCEL file is generated successfully, click <a href=users.xls target=_blank>Download</a>!
rsstData.Close
set rstData = nothing
Conn.Close
Set Conn = nothing
%>
Share: Separation of code and page in Asp In order to avoid maintenance difficulties caused by mixing ASP programs and HTML code, this article introduces a method to use templates to separate programs and pages to make programming easier. When using ASP to create a site, there is often a situation where the program code and HTML code are mixed in an ASP file. There are many disadvantages to doing this: 1. Not to mention programming, you need to