<% set fso=CreateObject("Scripting.FileSystemObject") set myexcell=CreateObject("Excel.Application") myexcell.Visible = True Randomize newfile="output" & Int(Rnd * 9000 + 1000) & ".xls" 'on error resume next if fso.FileExists(server.MapPath(newfile))=true then fso.DeleteFile server.MapPath(newfile) else set mywork=myexcell.Workbooks.Add '生成Excell文件就这两行代码,列名是原数据库的字段名。 mywork.SaveAs server.MapPath(newfile) sql="select * into [sheet1$] In '" & server.MapPath(newfile) & "' 'EXCEL 5.0;' from userfile" conn.execute sql rsclose() connclose() mywork.Close myexcell.Quit 'set mywork=nothing 'set myexcell=nothing set fso=nothing end if Response.ContentType="application/x-msdownload" response.Redirect(newfile) %>
ACCESS里面的表导出到EXCEL
最新推荐文章于 2017-08-18 11:01:07 发布