日期:2014-05-17  浏览次数:20936 次

asp 将数据导出为csv格式的文件 ,并提供下载的问题!
悬赏园豆:30 [待解决问题] 离问题结束还有 29 天 24 小时 浏览:2 次

我按照以下方法

<%

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输出来。请大家帮忙!!!谢谢!


------解决方案--------------------
那些也属于Response的内容,所以会一并返回。不想要就把它们都删除掉。