以下為引用的內(nèi)容:
<!--#include file="../conn.asp"-->
<%
if session("china_admin")="" then response.redirect "login.asp"
dbpath="../"
dblink
dim filename,fs,myfile,x,m,n,o,link
Set fs = server.CreateObject("scripting.filesystemobject")
Set rs = Server.CreateObject("ADODB.Recordset")
session("sql") = "select * from china_car"
rs.Open session("sql"),conn,1,1
n=1
'==================================================================
'==============================================================建立excel文件系統(tǒng)
filename = Server.MapPath("car/CarTable"&n&".xls") '這個(gè)是為了方便,新建一個(gè)CAR的文件夾,這個(gè)可以自己設(shè)啦
if fs.FileExists(filename) then'如果文件存在,覆蓋它。
fs.DeleteFile(filename)
end if
set myfile = fs.CreateTextFile(filename,true)
'========================================================================
dim strLine,responsestr
strLine=""
dim work,j,i
str="序號(hào)|卡號(hào)|密碼|積分?jǐn)?shù)|金額" '這個(gè)根據(jù)你的access數(shù)據(jù)表字段設(shè)置。
work=split(str,"|")
j=ubound(work)
i=0
o=0
do while not i>j
strLine= strLine & work(i) & chr(9)
i=i+1
loop
myfile.writeline strLine
Do while Not rs.EOF
o=o+1
m=20000
strLine=""
for each x in rs.Fields
strLine= strLine & x.value & chr(9)
if o>=m*n then
n=n+1
filename = Server.MapPath("car/CarTable"&n&".xls") '這個(gè)可以自己設(shè)啦
if fs.FileExists(filename) then'如果文件存在,覆蓋它。
fs.DeleteFile(filename)
end if
set myfile = fs.CreateTextFile(filename,true)
end if
next
myfile.writeline strLine
rs.MoveNext
loop
rs.Close
set rs = nothing
conn.close
set conn = nothing
set myfile = nothing
Set fs=Nothing
ExcelPath="car/CarTable"&n&".xls"
response.Write "導(dǎo)出成功 "
response.write("<a href='" & server.URLEncode(ExcelPath) & "'><font=red>下載</font></a>")
%>
|