当先锋百科网

首页 1 2 3 4 5 6 7
 

<!--#include file="Include/Functions.asp"-->

<%
'Response.ContentType = "application/vnd.ms-excel"
daytime=year(now())&"-"&month(now())&"-"&day(now())&"-"&hour(now())&"-"&Minute(now())
set rs=server.createobject("adodb.recordset")
sql="select * from T_title where ID=2"
rs.open sql,conn,1,1
Set ExcelApp =CreateObject("Excel.Application")
ExcelApp.Application.Visible = True
Set ExcelBook = ExcelApp.Workbooks.Add
'ExcelBook.WorkSheets(1).cells(1,1).value ="用户表" 
ExcelBook.WorkSheets(1).cells(2,1).value = "来信人姓名"
ExcelBook.WorkSheets(1).cells(2,2).value = "来信人联系电话"
ExcelBook.WorkSheets(1).cells(2,3).value = "IP地址"
ExcelBook.WorkSheets(1).cells(2,4).value = "信件主题"
ExcelBook.WorkSheets(1).cells(2,5).value = "信件内容"
ExcelBook.WorkSheets(1).cells(2,6).value = "处理单位"
ExcelBook.WorkSheets(1).cells(2,7).value = "处理状态"
cnt =3
do while not rs.eof
set rsc=server.CreateObject("adodb.recordset")
rsc.open"select bumen from T_bumen where ID="&trim(rs("chulibumen"))&"",conn,1,1
if not rsc.eof and not rsc.bof then
bumen=trim(rsc("bumen"))
end if
rsc.close
set rsc=nothing

ExcelBook.WorkSheets(1).cells(cnt,1).value = rs("UserName")
ExcelBook.WorkSheets(1).cells(cnt,2).value = rs("Tell")
ExcelBook.WorkSheets(1).cells(cnt,3).value = rs("IP")
ExcelBook.WorkSheets(1).cells(cnt,4).value = rs("Title")
ExcelBook.WorkSheets(1).cells(cnt,5).value = rs("Content")
ExcelBook.WorkSheets(1).cells(cnt,6).value = bumen
ExcelBook.WorkSheets(1).cells(cnt,7).value = rs("zhutai")
rs.movenext
cnt = cint(cnt) + 1
loop
Excelbook.SaveAs "D:\"&daytime&".xls"    '这个是数据导出完毕以后在D盘存成文件
ExcelApp.Application.Quit     '导出以后退出Excel
Set ExcelApp = Nothing     '注销Excel对象
'response.Write"<script>alert('"&daytime&"这个是数据导出完毕以后在D盘存成文件')<script>"
%>