首页 新闻 会员 周边

asp 将数据导出为csv格式的文件 ,并提供下载的问题!

0
悬赏园豆:30 [待解决问题]

我按照以下方法

<%

Response.Buffer = true
Response.AddHeader "Content-Disposition","attachment; filename=文件名_"&TxtFileName&".csv"   
Response.CharSet = "iso-8859-1" '文件编码
Response.ContentType = "application/octet-stream" 
set sql ="select * from test"
set rs = conn.Execute(sql)
Response.Write rs.fields(0).name
for i=1 to rs.fields.count-1
Response.Write ";" & rs.fields(i).name
next
Response.Flush()

do while not rs.eof
Response.Write vbCrLf & rs(0)
for i=1 to rs.fields.count-1
Response.Write ";" & rs(i)
next
Response.Flush()
rs.Movenext

loop
rs.Close
conn.Close
set rs = nothing
set conn = nothing
Response.End()

%>

为什么也输出了html标签里的内容.列如:

  "
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>双向转诊-省级平台</title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
.STYLE1 {font-size: 12px}
.STYLE3 {font-size: 12px; font-weight: bold; }
.STYLE4 {
    color: #03515d;
    font-size: 12px;
}
-->
</style>
 
<script src="../../_JS/yanse_table.js"></script>
 
<link href="../inc/css.css" rel="stylesheet" type="text/css" />
<link href="../../member/css.css" rel="stylesheet" type="text/css">
</head>
怎么不让这些html输出来。请大家帮忙!!!谢谢!
问题补充:

有没有兄弟帮忙下的。万分感谢,明天就要较差了

litte monkey的主页 litte monkey | 初学一级 | 园豆:25
提问于:2011-08-03 20:25
< >
分享
所有回答(1)
0

先使用 Response.Clear(); Response.ClearHeaders();

参考http://zhidao.baidu.com/question/123003815

2012 | 园豆:21230 (高人七级) | 2011-08-05 12:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册