一聚教程网:一个值得你收藏的教程网站

热门教程

将指定的记录生成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")

%>


 
  New Document
 
 
 
 
 
 
 

 
 


  asp教程" onsubmit="return fsubmit();">
 
 
 
 
 
   
   
 
  <%
  sql="select top 10 id,username,password,content,sex,ytime from users"
rs.open sql,conn,1,1
If rs.eof Then
Else
do while not rs.eof
    id = rs("id")
    username = rs("username")
    password = rs("password")
    content = rs("content")
    sex = rs("sex")
    ytime = rs("ytime")
    '******************下面是你要显示的******************'
 %>
 
 
 
 
 
   
   
 
 <%
    '******************上面是你要显示的******************'
rs.movenext
loop
End If
rs.close
%>
 
 
 
 
 
 
用户名密码内容性别发布时间
<%=username%><%=password%><%=content%><%=sex%> <%=ytime%>
 
  

 

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')"">"
%>

热门栏目