关于asp输出excel表格的问题

kikytang 2003-06-12 10:46:18
为什么报表会出现格式不正确?某些记录的字段换行
形如:
用户名 密码 作者
aa 123 54
aa 123
54

<%

dim fs, filename, strLine, myfile, link

Set fs = server.CreateObject("scripting.filesystemobject")
filename = gc_UploadTempPath_L & "\" & session("UserID") & ".xls"

if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
set myfile = fs.CreateTextFile(filename,true)

''strLine=""
strLine= "序号" & chr(9) & "图片标题" & chr(9) & "摄影师" & chr(9) & "首次下载时间" & chr(9) & "IP地址" & chr(9) & "下载用户"

myfile.writeline strLine

dim iMyCount
for iMyCount = 1 to nRecCount
dim myLine
myLine = rsDownloadLog("PicText")
''myLine=replace(myLine,chr(9), "")
strLine= iMyCount & chr(9) & myLine & chr(9) & rsDownloadLog("Author") & chr(9) & FormatDateTimeStr_excel(rsDownloadLog("dtDownload"), false, false) & chr(9) & rsDownloadLog("ip") & chr(9) & rsDownloadLog("UserID")
myfile.writeline strLine
rsDownloadLog.MoveNext
next

set fs=nothing

link="<A HREF=" & gc_UploadTempPath & session("UserID") & ".xls" & ">打开报表"
Response.write link

%>


...全文
33 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
leojeff 2003-06-12
  • 打赏
  • 举报
回复
你这样用tab拼字符串的办法不是很好

我建议你在循环中用2个变量来控制行和列,个人觉得这样比较好

比如:intRow intCol

for i = 1 to nRecCount

for j = 1 to intCol

'write a(i,j)
intCol = intCol + 1
next

intRow = intRow + 1
next
kikytang 2003-06-12
  • 打赏
  • 举报
回复
还是不太明白你的意思,能进对我这个写一下怎么循环吗?

28,391

社区成员

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

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