高手们,帮忙看看ASP生成EXECL吧,帮帮忙,完事给分

xiaopeng0803 2010-07-27 06:35:40
解释一下每行的意思?我知道很麻烦。。大家帮帮啊。ASP那个版块里没人了。只有到PHP里来看看

Set ExcelApp =CreateObject("Excel.Application")
ExcelApp.Application.Visible = false
on error resume next
Set ExcelBook = ExcelApp.Workbooks.add
award=cint(award)
ExcelBook.WorkSheets(1).cells(1,10).value =award&"等奖抽奖结果"
ExcelBook.WorkSheets(1).cells(2,1).value = "客户ID"
ExcelBook.WorkSheets(1).cells(2,2).value = "姓名"
ExcelBook.WorkSheets(1).cells(2,3).value = "性别"
ExcelBook.WorkSheets(1).cells(2,4).value = "手机号码"
'ExcelBook.WorkSheets(1).cells(2,5).value = "邮编"
ExcelBook.WorkSheets(1).cells(2,5).value = "地址"

cnt=3
content = content & "<tr><td>客户ID</td><td>姓名</td><td>性别</td><td>手机号码</td><td>地址</td></tr>"
if rs.eof and rs.bof then
response.Write("<script>alert('资源有限哦!');window.location='awardnew.asp';</script>")
response.end()
end if
do while not rs.eof
content = content & "<tr><td>"&rs("customerid")&"</td><td>"&rs("name")
'if rs("sex")=1 then content = content & "</td><td>" & "男"
'if rs("sex")=2 then content = content & "</td><td>" & "女"
'if rs("sex")=0 then content = content & "</td><td>" & "未知"
content =content & "</td><td>" & rs("sex")&"</td><td>" & rs("mobile") & "</td><td>" & rs("address")&"</td></tr>"
ExcelBook.WorkSheets(1).cells(cnt,1).value = rs("customerid")
ExcelBook.WorkSheets(1).cells(cnt,2).value = rs("name")
ExcelBook.WorkSheets(1).cells(cnt,3).value = rs("sex")
ExcelBook.WorkSheets(1).cells(cnt,4).value = rs("mobile")
'ExcelBook.WorkSheets(1).cells(cnt,5).value = rs("postcode")

ExcelBook.WorkSheets(1).cells(cnt,5).value = rs("address")
customerid=rs("customerid")
sql="delete from awardnew2 where customerid='"&customerid&"'"
'response.Write(sql)
'response.End()
conn.execute(sql)


rs.movenext
cnt = cint(cnt) + 1
loop
'names="E:\调查问卷\EOS2010\awards\" & year(now) & month(now) & day(now) & hour(now) & minute(now) & second(now) & ".xls"
'C:\mytestsite\canonvoiedcdv\dc\back\asp\Excel
names=server.MapPath("awards/" & year(now) & month(now) & day(now) & hour(now) & minute(now) & second(now) & ".xls")
Excelbook.SaveAS names '这个是数据导出完毕以后在D盘存成文件
' Excelbook.SaveAS(server.mappath("/") & "eos最新版\award.xls")
ExcelApp.Application.Quit '导出以后退出Excel
Set ExcelApp = Nothing '注销Excel对象
...全文
22 点赞 收藏 3
写回复
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaopeng0803 2010-07-27
[Quote=引用 1 楼 amani11 的回复:]

朋友,你好歹标示下,看懂了哪些

或者标示下,哪一行有问题??,,,代码不对,还是不理解
[/Quote]
不理解,每行都不理解
回复
CunningBoy 2010-07-27
出门,左转,ASP版
回复
amani11 2010-07-27
朋友,你好歹标示下,看懂了哪些

或者标示下,哪一行有问题??,,,代码不对,还是不理解
回复
发动态
发帖子
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
社区公告
暂无公告