|
-
- <!--#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文件系统
- filename = Server.MapPath("car/CarTable"&n&".xls") '这个是为了方便,新建一个CAR的文件夹,这个可以自己设啦
- 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="序号|卡号|密码|积分数|金额" '这个根据你的access数据表字段设置。
- 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") '这个可以自己设啦
- 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 "导出成功 "
- response.write("<a href='" & server.URLEncode(ExcelPath) & "'><font=red>下载</font></a>")
- %>
复制代码 |
|