<% ########## Implementation will dynamically generate an Excel form, and will And write ############################################################### Createby Guofeng ###################################################################### = "text / html; charset = GB2312" http-equiv = "content-type">
Generate Excel file title> head> Excel
<% if request ("act") = "" "" "" ####################################### ########## The main program start ########### '############### Code Createby Guofeng ########### DIM SQL, FileName, FS, MyFile, X, Link Set FS = Server.createObject ("scripting.filesystemObject") '- Suppose you want to generate The Excel file is made as follows for FileName = "E: / Longshan Memorial Lin Customer Management /Online.xls" - If the original Excel file exists, delete it if fs.fileexists (filename) Then fs.deletefile (filename) end if '- Create an Excel file set myfile = fs.createtextFile (filename, true) set = server.createObject ("adoDb.recordset")' - Put the data you want to put in Excel from the database "SQL = "Select Population, Hourpos, datepos from population / ryder by datepos, Hourpos ASC "SQL =" Select * from Basic ORDER BY ID "rs.open sql, conn if xi ie ############################################################################################################################################################################################################################################ ## Start Write ############ #################################################################################################################################################################################################################################################################################### ######## DIM strline, responsestr strline = "" for each x in rs.fields strline = strline & x.name & chr (9) Next '- Write the column name of the table to Excel Myfile. WriteLine strline
Do While Not Rs.eof Strline = "" for Each x in rs.fields strline = strline & x.value & chr (9) Next '- Write the data of the table to Excel MyFile.WriteLine Strliners.Movenext loop endix
Rs.closset RS = NothingConn.closset conn = NothingSet myfile = nothingset fs = Nothing
Link = " Open the Excel file " response.write linked if%> body> html>