| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2459 人关注过本帖
标题:asp 查询出来的数据导出excel格式问题
只看楼主 加入收藏
cxjyw
Rank: 1
等 级:新手上路
帖 子:55
专家分:0
注 册:2006-1-10
结帖率:100%
收藏
 问题点数:0 回复次数:20 
asp 查询出来的数据导出excel格式问题

将asp查询出来的数据导出excel格式,怎么实现呀,在网上找了大堆的代码做了,还是不行?希望大家帮忙解决。谢了。

搜索更多相关主题的帖子: excel asp 数据 格式 查询 
2007-06-24 23:20
xiaohonghui0
Rank: 1
等 级:新手上路
威 望:1
帖 子:274
专家分:0
注 册:2006-4-10
收藏
得分:0 

保存为excel格式:
<%
if request.cookies("flag")< 1 then
response.redirect "error.htm"
response.End
end if
%> '这是我设置的权限,你可以删掉
<!--#include file="conn.asp"--> '数据库连接文件
<%
Response.ContentType = "application/vnd.ms-excel"
filename="CHINACOAT_NAME" '要保存的excel表格名
Response.AddHeader "content-disposition", "attachment; filename=" & filename & ".xls"
%>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> '下面是设置的表格,里面是数据库对应内容
<table width="90%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Exh
name<br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Co.
Name in Eng</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Co.
Name in Chinese</strong></font></div></td>
<td bgcolor="#FFFFFF"><div align="center"><strong>Chinese (Eng) Name</strong></div></td>
<%
set rs= server.CreateObject("adodb.recordset")
rs.open " select * from detail order by shortname asc",myconn,1,1 '查询语句
%>
<td> <div align="center"><font color="#FFFFFF"><strong><font color="#000000">Origin</font><br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Origin
(Chinese)</strong></font><font color="#FFFFFF"></font></div></td>
<td bgcolor="#FFFFFF"><div align="center"><strong>Follow up office</strong></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Rep
by<br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>NEW<br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Hall</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Zone
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Booth
No.</strong></font><font color="#FFFFFF"></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Profile(chi)<br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Profile</strong></font></div></td>
<td bgcolor="#FFFFFF"><div align="center"><strong>Add people</strong></div></td>
<td bgcolor="#FFFFFF"><div align="center"><strong>Add date</strong></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><strong><font color="#000000">update
people </font></strong></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><strong><font color="#000000">update
date </font></strong></div></td>
</tr>
<%do while not rs.eof%>
<tr>
<td> <div align="center"><%=rs("shortname")%></div></td>
<td><div align="center"><%=rs("companyeng")%> </div></td>
<td><%=rs("companychi")%> </td>
<td><%=rs("companychieng")%></td>
<td><div align="center"><%=rs("country")%> </div></td>
<td><%=rs("countrychi")%></td>
<td><%=rs("followup")%></td>
<td><div align="center"><%=rs("representby")%> </div></td>
<td> <div align="center"> <%=rs("new1") %> </div></td>
<td><div align="center"><%=rs("hall")%> </div></td>
<td> <div align="center"><%=rs("zone1")%></div></td>
<td> <div align="center"><%=rs("boothnumber")%></div></td>
<td> <div align="center">
<%if rs("instrchi") <>"" then response.write "Yes" end if%>
</div></td>
<td>
<%if rs("instreng") <>"" then response.write "Yes" end if%>
</td>
<td><%=rs("addman")%></td>
<td><%=year(rs("timeaddman"))&"-"&month(rs("timeaddman"))&"-"&day(rs("timeaddman"))%></td>
<td>
<%if rs("flag")>2 then%>
<%=rs("admin")%>
<%end if%>
</td>
<td>
<%if rs("flag")>2 then%>
<%=year(rs("time2"))&"-"&month(rs("time2"))&"-"&day(rs("time2"))%>
<%end if%>
</td>
</tr>
<%rs.movenext
loop
rs.close
set rs=nothing
%>
</table>


再给你发个保存为word文档的:
<%
Response.ContentType = "application/vnd.ms-word"
filename="CHINACOAT_SELECT"
Response.AddHeader "content-disposition", "attachment; filename=" & filename & ".doc"
%>
<%
if request.cookies("flag")< 1 then
response.redirect "error.htm"
response.End
end if
%>
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<%
if request.cookies("flag")< 1 then
response.redirect "error.htm"
response.End
end if
%>
<p>
<!--#include file="conn.asp"-->
<%
dim a1,b1,c1,d,e,f,g,h,i,j,k,l,m,n,o,p
a1=request.Form("int1") '展台号
b1=request.Form("int2") '新展商
c1=request.Form("int3") 'reprenstby
d=request.Form("int4") '公司名
e=request.Form("int5") '公司名中文
f=request.Form("int6") '地址
o=request.Form("int14") '中文地址
p=request.Form("int15") '附加资料
g=request.Form("int7") '邮遍
h=request.Form("int8") '电话
i=request.Form("int9") '传真
j=request.Form("int10") '电邮
k=request.Form("int11") '网址
l=request.Form("int12") '公司简介英文
m=request.Form("int13") '公司简介中文
%>
<%
dim a,b,c
a=request.Form("user")
b=request.Form("zone")
if a="All" then
a=""
end if
c=request.Form("office")
if c="All" then
c=""
end if
dim sql
yy=""
yy1=""
if a<>"" then
yy="admin="&a
end if
if c<>"" then
yy1=" followup="&c
end if
sql="select * from detail where admin='"&a&"' and zone1='3' or zone1='4' and followup='"&c&"' order by shortname asc "
set rs=server.CreateObject("adodb.recordset")
rs.Open sql,myconn,1,1
do while not rs.eof
%>
</p>
<p><%if a1<>"" then%>展台号:<%=rs("boothnumber")%><br><%end if%>
<%if b1<>"" then%><%=rs("new1")%><br><%end if%>
<%if c1<>"" then%><%=rs("representby")%><br><%end if%>
<%if d<>"" then%><%=rs("companyeng")%><br><%end if%>
<%if e<>"" then%><%=rs("companychi")%><br><%end if%>
<%if f<>"" then%><%=rs("address")%><br><%end if%>
<%if o<>"" then%><%=rs("addresschi")%><br><%end if%>
<%if g<>"" then%>邮编:<%=rs("post")%><br><%end if%>
<%if h<>"" then%>电话:<%=rs("phone")%><br><%end if%>
<%if i<>"" then%>传真:<%=rs("fax")%><br><%end if%>
<%if j<>"" then%>电邮:<%=rs("email")%><br><%end if%>
<%if k<>"" then%>网址:<%=rs("website")%><br><br><%end if%>
<%if p<>"" then%><%=rs("attached")%><br><br><%end if%>
<%if l<>"" then%><%=rs("instreng")%><br><br><%end if%>
<%if m<>"" then%><%=rs("instrchi")%><%end if%></p>
<%
rs.movenext
loop
rs.close
set rs=nothing
myconn.close
set myconn=nothing
%>
</body>
</html>

上面的代码都是我用过的,绝对可行,你修改试下

[此贴子已经被阳光白雪于2007-6-27 17:24:06编辑过]


曾用asp做过公司管理系统,新闻发布系统,个人网站之类,可代做网站 有意者请联系我,电话:13714123661
2007-06-25 12:17
xiaohonghui0
Rank: 1
等 级:新手上路
威 望:1
帖 子:274
专家分:0
注 册:2006-4-10
收藏
得分:0 
以下是引用xiaohonghui0在2007-6-25 12:17:19的发言:

保存为excel格式:
<%
if request.cookies("flag")< 1 then
response.redirect "error.htm"
response.End
end if
%> '这是我设置的权限,你可以删掉
<!--#include file="conn.asp"--> '数据库连接文件
<%
Response.ContentType = "application/vnd.ms-excel"
filename="CHINACOAT_NAME" '要保存的excel表格名
Response.AddHeader "content-disposition", "attachment; filename=" & filename & ".xls"
%>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> '下面是设置的表格,里面是数据库对应内容
<table width="90%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Exh
name<br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Co.
Name in Eng</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Co.
Name in Chinese</strong></font></div></td>
<td bgcolor="#FFFFFF"><div align="center"><strong>Chinese (Eng) Name</strong></div></td>
<%
set rs= server.CreateObject("adodb.recordset")
rs.open " select * from detail order by shortname asc",myconn,1,1 '查询语句
%>
<td> <div align="center"><font color="#FFFFFF"><strong><font color="#000000">Origin</font><br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Origin
(Chinese)</strong></font><font color="#FFFFFF"></font></div></td>
<td bgcolor="#FFFFFF"><div align="center"><strong>Follow up office</strong></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Rep
by<br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>NEW<br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Hall</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Zone
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Booth
No.</strong></font><font color="#FFFFFF"></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Profile(chi)<br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Profile</strong></font></div></td>
<td bgcolor="#FFFFFF"><div align="center"><strong>Add people</strong></div></td>
<td bgcolor="#FFFFFF"><div align="center"><strong>Add date</strong></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><strong><font color="#000000">update
people </font></strong></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><strong><font color="#000000">update
date </font></strong></div></td>
</tr>
<%do while not rs.eof%>
<tr>
<td> <div align="center"><%=rs("shortname")%></div></td>
<td><div align="center"><%=rs("companyeng")%> </div></td>
<td><%=rs("companychi")%> </td>
<td><%=rs("companychieng")%></td>
<td><div align="center"><%=rs("country")%> </div></td>
<td><%=rs("countrychi")%></td>
<td><%=rs("followup")%></td>
<td><div align="center"><%=rs("representby")%> </div></td>
<td> <div align="center"> <%=rs("new1") %> </div></td>
<td><div align="center"><%=rs("hall")%> </div></td>
<td> <div align="center"><%=rs("zone1")%></div></td>
<td> <div align="center"><%=rs("boothnumber")%></div></td>
<td> <div align="center">
<%if rs("instrchi") <>"" then response.write "Yes" end if%>
</div></td>
<td>
<%if rs("instreng") <>"" then response.write "Yes" end if%>
</td>
<td><%=rs("addman")%></td>
<td><%=year(rs("timeaddman"))&"-"&month(rs("timeaddman"))&"-"&day(rs("timeaddman"))%></td>
<td>
<%if rs("flag")>2 then%>
<%=rs("admin")%>
<%end if%>
</td>
<td>
<%if rs("flag")>2 then%>
<%=year(rs("time2"))&"-"&month(rs("time2"))&"-"&day(rs("time2"))%>
<%end if%>
</td>
</tr>
<%rs.movenext
loop
rs.close
set rs=nothing
%>
</table>


再给你发个保存为word文档的:
<%
Response.ContentType = "application/vnd.ms-word"
filename="CHINACOAT_SELECT"
Response.AddHeader "content-disposition", "attachment; filename=" & filename & ".doc"
%>
<%
if request.cookies("flag")< 1 then
response.redirect "error.htm"
response.End
end if
%>
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<%
if request.cookies("flag")< 1 then
response.redirect "error.htm"
response.End
end if
%>
<p>
<!--#include file="conn.asp"-->
<%
dim a1,b1,c1,d,e,f,g,h,i,j,k,l,m,n,o,p
a1=request.Form("int1") '展台号
b1=request.Form("int2") '新展商
c1=request.Form("int3") 'reprenstby
d=request.Form("int4") '公司名
e=request.Form("int5") '公司名中文
f=request.Form("int6") '地址
o=request.Form("int14") '中文地址
p=request.Form("int15") '附加资料
g=request.Form("int7") '邮遍
h=request.Form("int8") '电话
i=request.Form("int9") '传真
j=request.Form("int10") '电邮
k=request.Form("int11") '网址
l=request.Form("int12") '公司简介英文
m=request.Form("int13") '公司简介中文
%>
<%
dim a,b,c
a=request.Form("user")
b=request.Form("zone")
if a="All" then
a=""
end if
c=request.Form("office")
if c="All" then
c=""
end if
dim sql
yy=""
yy1=""
if a<>"" then
yy="admin="&a
end if
if c<>"" then
yy1=" followup="&c
end if
sql="select * from detail where admin='"&a&"' and zone1='3' or zone1='4' and followup='"&c&"' order by shortname asc "
set rs=server.CreateObject("adodb.recordset")
rs.Open sql,myconn,1,1
do while not rs.eof
%>
</p>
<p><%if a1<>"" then%>展台号:<%=rs("boothnumber")%><br><%end if%>
<%if b1<>"" then%><%=rs("new1")%><br><%end if%>
<%if c1<>"" then%><%=rs("representby")%><br><%end if%>
<%if d<>"" then%><%=rs("companyeng")%><br><%end if%>
<%if e<>"" then%><%=rs("companychi")%><br><%end if%>
<%if f<>"" then%><%=rs("address")%><br><%end if%>
<%if o<>"" then%><%=rs("addresschi")%><br><%end if%>
<%if g<>"" then%>邮编:<%=rs("post")%><br><%end if%>
<%if h<>"" then%>电话:<%=rs("phone")%><br><%end if%>
<%if i<>"" then%>传真:<%=rs("fax")%><br><%end if%>
<%if j<>"" then%>电邮:<%=rs("email")%><br><%end if%>
<%if k<>"" then%>网址:<%=rs("website")%><br><br><%end if%>
<%if p<>"" then%><%=rs("attached")%><br><br><%end if%>
<%if l<>"" then%><%=rs("instreng")%><br><br><%end if%>
<%if m<>"" then%><%=rs("instrchi")%><%end if%></p>
<%
rs.movenext
loop
rs.close
set rs=nothing
myconn.close
set myconn=nothing
%>
</body>
</html>

上面的代码都是我用过的,绝对可行,你修改试下

开始发的代码不知道为何是乱吗,我订正了下,你们再看看.

[此贴子已经被阳光白雪于2007-6-27 17:24:29编辑过]


曾用asp做过公司管理系统,新闻发布系统,个人网站之类,可代做网站 有意者请联系我,电话:13714123661
2007-06-26 23:38
hangxj
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2045
专家分:0
注 册:2006-4-10
收藏
得分:0 
楼上的,麻烦重新编辑一下你的东东吧,看得头大

http://www./
2007-06-27 10:32
hangxj
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2045
专家分:0
注 册:2006-4-10
收藏
得分:0 
给你一个相关的代码,具体的你自己去研究与修改

[QUOTE]<%
dim referer
referer = Request.ServerVariables("HTTP_REFERER")
Dim CName,action
action=request.Form("action")
CName="Excel/"
dim daytime
daytime=year(now())&"年"&month(now())&"月"&day(now())&"日"&hour(now())&"时"
Set rs = Server.CreateObject("ADODB.Recordset")
'--从数据库中把你想放到EXCEL中的数据查出来
sql="select * from gbook order by id desc"
rs.Open sql,conn
if rs.EOF and rs.BOF then
response.write 操作出错,下面是产生错误的可能原因:库里暂时没有数据,所以不能导出EXCEL文件!"
response.end
else
dim filename,fs,myfile,x
Set fs = server.CreateObject("scripting.filesystemobject")
'--假设你想让生成的EXCEL文件做如下的存放
filename = Server.MapPath(""&CName&""&daytime&".xls")
'--如果原来的EXCEL文件存在的话删除它
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
'--创建EXCEL文件
set myfile = fs.CreateTextFile(filename,true)
dim strLine,responsestr
strLine=""
For each x in rs.fields
strLine= strLine & x.name & chr(9)
Next
'--将表的列名先写入EXCEL
myfile.writeline strLine
Do while Not rs.EOF
strLine=""
for each x in rs.Fields
strLine= strLine & x.value & chr(9)
next
'--将表的数据写入EXCEL
myfile.writeline strLine
rs.MoveNext
loop
rs.Close
set rs = nothing
conn.close
set conn = nothing
set myfile = nothing
Set fs=Nothing
Response.Write "<BR><BR><center><b>导出成功,请选择继续操作</b></center>"
Response.Write "<br>"
response.Write "<table width=90% cellspacing=1 cellpadding=3 align=center>"
Response.Write "<tr align=center> <td>"
response.write ("<font color=green>√</font><a href='"&CName&""&daytime&".xls'>下载</a>") & "&nbsp;&nbsp;<font color= green>√</font><a href='"&referer&"'>返回</a>"
Response.Write "</td></tr></table>"
end if
%>[/QUOTE]

http://www./
2007-06-27 10:35
hangxj
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2045
专家分:0
注 册:2006-4-10
收藏
得分:0 
给出这份相关代码后,我不再提供任何的解答

如果给了你这份代码,你得不到自己想要的,我也帮不到你!


http://www./
2007-06-27 10:36
SkyGull
Rank: 5Rank: 5
来 自:浙江杭州
等 级:贵宾
威 望:13
帖 子:839
专家分:324
注 册:2007-6-7
收藏
得分:0 

郁闷..

发源码的时候code一下

[此贴子已经被作者于2007-6-27 11:10:27编辑过]

2007-06-27 11:09
xiaohonghui0
Rank: 1
等 级:新手上路
威 望:1
帖 子:274
专家分:0
注 册:2006-4-10
收藏
得分:0 

我就是不知道怎么编辑,特地还发了个问管理员怎么弄?
我的那个帖子你点引用就可以用了


曾用asp做过公司管理系统,新闻发布系统,个人网站之类,可代做网站 有意者请联系我,电话:13714123661
2007-06-27 12:01
SkyGull
Rank: 5Rank: 5
来 自:浙江杭州
等 级:贵宾
威 望:13
帖 子:839
专家分:324
注 册:2007-6-7
收藏
得分:0 

把你的代码全中再按一下[IMG]http://bbs.bc-cn.net/images/post/code.gif[/IMG]

2007-06-27 12:05
xiaohonghui0
Rank: 1
等 级:新手上路
威 望:1
帖 子:274
专家分:0
注 册:2006-4-10
收藏
得分:0 
以下是引用xiaohonghui0在2007-6-25 12:17:19的发言:

保存为excel格式:
<%
if request.cookies("flag")< 1 then
response.redirect "error.htm"
response.End
end if
%> '这是我设置的权限,你可以删掉
<!--#include file="conn.asp"--> '数据库连接文件
<%
Response.ContentType = "application/vnd.ms-excel"
filename="CHINACOAT_NAME" '要保存的excel表格名
Response.AddHeader "content-disposition", "attachment; filename=" & filename & ".xls"
%>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> '下面是设置的表格,里面是数据库对应内容
<table width="90%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Exh
name<br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Co.
Name in Eng</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Co.
Name in Chinese</strong></font></div></td>
<td bgcolor="#FFFFFF"><div align="center"><strong>Chinese (Eng) Name</strong></div></td>
<%
set rs= server.CreateObject("adodb.recordset")
rs.open " select * from detail order by shortname asc",myconn,1,1 '查询语句
%>
<td> <div align="center"><font color="#FFFFFF"><strong><font color="#000000">Origin</font><br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Origin
(Chinese)</strong></font><font color="#FFFFFF"></font></div></td>
<td bgcolor="#FFFFFF"><div align="center"><strong>Follow up office</strong></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Rep
by<br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>NEW<br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Hall</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Zone
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Booth
No.</strong></font><font color="#FFFFFF"></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Profile(chi)<br>
</strong></font></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><font color="#000000"><strong>Profile</strong></font></div></td>
<td bgcolor="#FFFFFF"><div align="center"><strong>Add people</strong></div></td>
<td bgcolor="#FFFFFF"><div align="center"><strong>Add date</strong></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><strong><font color="#000000">update
people </font></strong></div></td>
<td bgcolor="#FFFFFF"> <div align="center"><strong><font color="#000000">update
date </font></strong></div></td>
</tr>
<%do while not rs.eof%>
<tr>
<td> <div align="center"><%=rs("shortname")%></div></td>
<td><div align="center"><%=rs("companyeng")%> </div></td>
<td><%=rs("companychi")%> </td>
<td><%=rs("companychieng")%></td>
<td><div align="center"><%=rs("country")%> </div></td>
<td><%=rs("countrychi")%></td>
<td><%=rs("followup")%></td>
<td><div align="center"><%=rs("representby")%> </div></td>
<td> <div align="center"> <%=rs("new1") %> </div></td>
<td><div align="center"><%=rs("hall")%> </div></td>
<td> <div align="center"><%=rs("zone1")%></div></td>
<td> <div align="center"><%=rs("boothnumber")%></div></td>
<td> <div align="center">
<%if rs("instrchi") <>"" then response.write "Yes" end if%>
</div></td>
<td>
<%if rs("instreng") <>"" then response.write "Yes" end if%>
</td>
<td><%=rs("addman")%></td>
<td><%=year(rs("timeaddman"))&"-"&month(rs("timeaddman"))&"-"&day(rs("timeaddman"))%></td>
<td>
<%if rs("flag")>2 then%>
<%=rs("admin")%>
<%end if%>
</td>
<td>
<%if rs("flag")>2 then%>
<%=year(rs("time2"))&"-"&month(rs("time2"))&"-"&day(rs("time2"))%>
<%end if%>
</td>
</tr>
<%rs.movenext
loop
rs.close
set rs=nothing
%>
</table>


再给你发个保存为word文档的:
<%
Response.ContentType = "application/vnd.ms-word"
filename="CHINACOAT_SELECT"
Response.AddHeader "content-disposition", "attachment; filename=" & filename & ".doc"
%>
<%
if request.cookies("flag")< 1 then
response.redirect "error.htm"
response.End
end if
%>
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<%
if request.cookies("flag")< 1 then
response.redirect "error.htm"
response.End
end if
%>
<p>
<!--#include file="conn.asp"-->
<%
dim a1,b1,c1,d,e,f,g,h,i,j,k,l,m,n,o,p
a1=request.Form("int1") '展台号
b1=request.Form("int2") '新展商
c1=request.Form("int3") 'reprenstby
d=request.Form("int4") '公司名
e=request.Form("int5") '公司名中文
f=request.Form("int6") '地址
o=request.Form("int14") '中文地址
p=request.Form("int15") '附加资料
g=request.Form("int7") '邮遍
h=request.Form("int8") '电话
i=request.Form("int9") '传真
j=request.Form("int10") '电邮
k=request.Form("int11") '网址
l=request.Form("int12") '公司简介英文
m=request.Form("int13") '公司简介中文
%>
<%
dim a,b,c
a=request.Form("user")
b=request.Form("zone")
if a="All" then
a=""
end if
c=request.Form("office")
if c="All" then
c=""
end if
dim sql
yy=""
yy1=""
if a<>"" then
yy="admin="&a
end if
if c<>"" then
yy1=" followup="&c
end if
sql="select * from detail where admin='"&a&"' and zone1='3' or zone1='4' and followup='"&c&"' order by shortname asc "
set rs=server.CreateObject("adodb.recordset")
rs.Open sql,myconn,1,1
do while not rs.eof
%>
</p>
<p><%if a1<>"" then%>展台号:<%=rs("boothnumber")%><br><%end if%>
<%if b1<>"" then%><%=rs("new1")%><br><%end if%>
<%if c1<>"" then%><%=rs("representby")%><br><%end if%>
<%if d<>"" then%><%=rs("companyeng")%><br><%end if%>
<%if e<>"" then%><%=rs("companychi")%><br><%end if%>
<%if f<>"" then%><%=rs("address")%><br><%end if%>
<%if o<>"" then%><%=rs("addresschi")%><br><%end if%>
<%if g<>"" then%>邮编:<%=rs("post")%><br><%end if%>
<%if h<>"" then%>电话:<%=rs("phone")%><br><%end if%>
<%if i<>"" then%>传真:<%=rs("fax")%><br><%end if%>
<%if j<>"" then%>电邮:<%=rs("email")%><br><%end if%>
<%if k<>"" then%>网址:<%=rs("website")%><br><br><%end if%>
<%if p<>"" then%><%=rs("attached")%><br><br><%end if%>
<%if l<>"" then%><%=rs("instreng")%><br><br><%end if%>
<%if m<>"" then%><%=rs("instrchi")%><%end if%></p>
<%
rs.movenext
loop
rs.close
set rs=nothing
myconn.close
set myconn=nothing
%>
</body>
</html>

上面的代码都是我用过的,绝对可行,你修改试下

不知道这回的代码还是不是乱码

[此贴子已经被阳光白雪于2007-6-27 17:24:59编辑过]


曾用asp做过公司管理系统,新闻发布系统,个人网站之类,可代做网站 有意者请联系我,电话:13714123661
2007-06-27 12:27
快速回复:asp 查询出来的数据导出excel格式问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018747 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved