从数据库导出到Excel文件,文件中中文显示乱码!

zhusuhao 2004-12-08 10:27:44
打开该文件的时候提示该文件或者有错误,或者不是SYLK文件格式

代码如下,请大家帮忙看看
dim rs,sql,filename,fs,myfile,x,link
sql=request("sql")
Set fs = server.CreateObject("scripting.filesystemobject")
filename = Server.mappath("file/online.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 * from 首页推荐"
rs.Open sql,conn
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
'response.write strLine
' response.end
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
conn.close
set conn = nothing
set myfile = nothing
Set fs=Nothing
...全文
378 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhusuhao 2004-12-09
  • 打赏
  • 举报
回复
谢谢cheng17(+天空+)
cheng17 2004-12-08
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3451/3451656.xml?temp=2.511233E-02
cheng17 2004-12-08
  • 打赏
  • 举报
回复
记得论坛上有,你搜索一下吧,我现在用的也是在论坛上找的,但我的是查询出来显示在页面再导入EXCEL
zhusuhao 2004-12-08
  • 打赏
  • 举报
回复
请各位高手帮帮忙

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧