最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
将指定的记录生成excel文件
时间:2022-07-02 23:03:33 编辑:袖梨 来源:一聚教程网
<%
DB="db1.mdb"
path=Server.MapPath(DB)
set conn=server.createobject("adodb.Connection")
connstr="provider=Microsoft.Jet.OLEDB.4.0;Data Source="&path
conn.Open connstr
Set rs=server.CreateObject("adodb.recordset")
%>
1.asp文件
<%
'功能:将指定的记录生成excel文件
'作者:wangsdong
id=request("id")
set Conn =server.CreateObject("adodb.connection")
ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.open ConnStr
dim rs,sql,filename,fs,myfile,x
Set fs = server.CreateObject("scripting.filesystemobject")
filename = Server.MapPath("111cn.net教程.xls")
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
set myfile = fs.CreateTextFile(filename,true)
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select id,username,password,content,sex,ytime from users where id in("&id&")"
rs.Open sql,conn,1,1
if rs.EOF and rs.BOF then
else
dim strLine,responsestr
strLine=""
For each x in rs.fields
strLine = strLine & x.name & chr(9)
Next
myfile.writeline strLine
Do while Not rs.EOF
strLine=""
for each x in rs.Fields
strLine = strLine & x.value & chr(9)
next
myfile.writeline strLine
rs.MoveNext
loop
end if
rs.Close
set rs = nothing
Response.Write "生成EXCEL文件成功!下载:javascript教程:window.open('aspprogra.xls')"">"
%>