| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1079 人关注过本帖
标题:ASP导出Excel,汉字变成了乱码,如何解决?
只看楼主 加入收藏
dh2007
Rank: 1
等 级:新手上路
帖 子:228
专家分:0
注 册:2007-2-28
结帖率:0
收藏
 问题点数:0 回复次数:1 
ASP导出Excel,汉字变成了乱码,如何解决?

<!--#include file="conn.asp"-->
<%
Response.ContentType="text/html"
Response.Charset="gb2312"

srhType=request("type")
srhKey=trim(request("key"))
if isempty(request("page")) or trim(request("page"))="" then
page=1
else
page=clng(request("page"))
end if
%>
<table width="99%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr bgcolor="#E8F1FF" align="center">
<td>手机号码</td>
<td>短信类别</td>
</tr>
<%
set getInf=server.CreateObject("ADODB.Recordset")
getInf_sql="select * from [Note] where 1=1 "
if srhType<>"" then
getInf_sql=getInf_sql&"and dxpt_TelType="&clng(srhType)&" "
end if
if srhKey<>"" then
getInf_sql=getInf_sql&"and dxpt_TelNumber='"&srhKey&"' "
end if
getInf_sql=getInf_sql&"order by id desc"


getInf.open getInf_sql,conn,1,1
getInf.PageSize=5000
if page=0 then
page=1
end if
pages=getInf.PageCount
if page > pages then
page=pages
end if
getInf.AbsolutePage = page
for j=1 to getInf.PageSize
%>
<tr bgcolor="#FFFFFF" align="center">
<td><%=getInf("dxpt_TelNumber")%></td>
<td>
<%
set Get_TypeName=server.CreateObject("ADODB.Recordset")
Get_TypeName_Sql="select * from NoteSort where dxpt_SortID="&getInf("dxpt_TelType")
Get_TypeName.open Get_TypeName_Sql,conn,1,1
if not Get_TypeName.eof then
response.Write Get_TypeName("dxpt_SortName")
end if
Get_TypeName.close
set Get_TypeName=nothing
%> </td>
</tr>
<%
getInf.movenext
if getInf.eof then
exit for
end if
next
%>
<%
getInf.close
set getInf=nothing
%>
</table>
<%
dim fname
fname = now()
fname = replace(fname,"-","")
fname = replace(fname," ","")
fname = replace(fname,":","")
fname = replace(fname,"PM","")
fname = replace(fname,"AM","")
fname = replace(fname,"上午","")
fname = replace(fname,"下午","")
fname = int(fname) + int((10-1+1)*Rnd + 1)
response.ContentType ="application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=" & fname
%>
帮忙看下

[此贴子已经被作者于2007-10-11 12:48:55编辑过]

搜索更多相关主题的帖子: Excel 乱码 汉字 ASP 
2007-10-11 12:48
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
Response.ContentType="text/html"楼主设置了该页为excel文件,为何还要设置text/html?
2007-10-11 22:42
快速回复:ASP导出Excel,汉字变成了乱码,如何解决?
数据加载中...
 
   



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

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