将sql里的数据导到excel

tianlebest 2011-04-29 06:24:10
现在有个数据表里面有数据 几十万 ,想导出到excel 里,不知道如何实现 啊,我要导出的只有一个字段 里的数据,最好是在excel的每个单元格都能写数据
...全文
49 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hongmei85 2011-04-29
  • 打赏
  • 举报
回复
参考下<%
Set xlApplication = Server.CreateObject("Excel.Application")
xlApplication.DisplayAlerts = false
xlApplication.Visible = false
xlApplication.SheetsInNewWorkbook=1
set xlBook=xlApplication.Workbooks.Add
Set xlWorksheet = xlBook.sheets(1)
xlWorksheet.name="Sector message"
xlWorksheet.Range(xlWorksheet.Cells(1,1), xlWorksheet.Cells(1,5)).MergeCells =True
xlWorksheet.Range("A1").value="个人比赛信息" '这个是设置EXECL 标题
xlWorksheet.Range("A1").font.Size=14
xlWorksheet.Range("A1").font.bold=true'
xlWorksheet.Range("A1").HorizontalAlignment=3
xlWorksheet.Range("A1").VerticalAlignment=3
xlWorksheet.Range("A2:D2").font.Size=11
xlWorksheet.Cells(2,1).Value = "项目名称"
xlWorksheet.Cells(2,2).Value = "学号"
xlWorksheet.Cells(2,3).Value = "姓名"
xlWorksheet.Cells(2,4).Value = "性别"
xlWorksheet.Cells(2,5).Value = "院系"


dim save_xslfile
save_xslfile="athlete_game_information.xls"
Set fs = server.CreateObject("Scripting.FileSystemObject")
tfile=Server.MapPath(save_xslfile)
if fs.FileExists(tfile) then
Set f = fs.GetFile(tfile)
f.delete true
Set f = nothing
end if
Set fs = nothing
xlBook.SaveCopyAs tfile
xlBook.saved=true
xlBook.close
xlApplication.Application.Quit
Set xlWorksheet = Nothing
Set xlApplication = Nothing
%>

28,391

社区成员

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

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