• Asp 导出Excel


    <%
    Dim xlWorkSheet
    Dim xlApplication
    Set xlApplication = Server.CreateObject("Excel.Application")
    xlApplication.Visible = False
    xlApplication.Workbooks.Add
    Set xlWorksheet = xlApplication.Worksheets(1)
    set oRS=Server.CreateObject("ADODB.Recordset")
    if Request("ImportExcel")="ImportExcel" then
      'If Response.IsClientConnected Then 
    '  Response.Flush 
    '  Else 
    '  Response.End
    '  End If
      Response.Expires = 0
      Response.Expiresabsolute = Now() - 1
      Response.AddHeader "Content-type","application/octet-stream"
      Response.AddHeader "Accept-Ranges","bytes"
      Response.AddHeader "Content-Disposition","attachment; filename=kl178exp.xls"
      'Response.ContentType = "application/msexcel"
      sql =session("SQL")  
      oRS.open sql,conns,1,3,1
      xlWorksheet.Cells(1,1).Value = "用户名"
      xlWorksheet.Cells(1,2).Value = "真实姓名"
      xlWorksheet.Cells(1,3).Value = "用户类型"
      xlWorksheet.Cells(1,4).Value = "注册时间"
      xlWorksheet.Cells(1,5).Value = "首次登录时间"
      xlWorksheet.Cells(1,6).Value = "最后登录时间"
      xlWorksheet.Cells(1,7).Value = "使用频率"
      xlWorksheet.Cells(1,8).Value = "停留时间"
      xlWorksheet.Cells(1,9).Value = "券商名称"
      xlWorksheet.Cells(1,10).Value = "业务员"
      xlWorksheet.Cells(1,1).Interior.ColorIndex = 16
      xlWorksheet.Cells(1,2).Interior.ColorIndex = 16
      xlWorksheet.Cells(1,3).Interior.ColorIndex = 16
      xlWorksheet.Cells(1,4).Interior.ColorIndex = 16
      xlWorksheet.Cells(1,5).Interior.ColorIndex = 16
      xlWorksheet.Cells(1,6).Interior.ColorIndex = 16
      xlWorksheet.Cells(1,7).Interior.ColorIndex = 16
      xlWorksheet.Cells(1,8).Interior.ColorIndex = 16
      xlWorksheet.Cells(1,9).Interior.ColorIndex = 16
      xlWorksheet.Cells(1,10).Interior.ColorIndex=16
      xlWorksheet.Cells(1,4).ColumnWidth=20
      xlWorksheet.Cells(1,5).ColumnWidth=20
      xlWorksheet.Cells(1,6).ColumnWidth=20
      
      iRow = 2
      If Not oRS.EOF Then
       Do Until oRS.EOF
      xlWorksheet.Cells(iRow,1).Value = oRS("UserName")
      xlWorksheet.Cells(iRow,2).Value = oRS("realName")
      xlWorksheet.Cells(iRow,3).Value = GetUserType(oRS("Usertype"))
      xlWorksheet.Cells(iRow,4).Value = FormatDate(oRS("RegisterTime"))
      xlWorksheet.Cells(iRow,5).Value = FormatDate(oRS("FirstLoginTime"))
      xlWorksheet.Cells(iRow,6).Value = FormatDate(oRS("LastLoginTime"))
      xlWorksheet.Cells(iRow,7).Value = oRS("UsedGroup")
      xlWorksheet.Cells(iRow,8).Value = oRS("UsedTime")
      xlWorksheet.Cells(iRow,9).Value = GetCompanyNameByID(oRS("CompanyID"))
      xlWorksheet.Cells(iRow,10).Value =oRS("introducer")
      iRow = iRow + 1
      oRS.MoveNext
      Loop
      End If
       rannum=int(1000*rnd)
       YoureIp=trim(Request.ServerVariables("REMOTE_ADDR"))
       YoureIp=left(YoureIp,len(YoureIp)-4)
       YoureIp=replace(YoureIp,".","")
      rndfile=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&rannum&YoureIp
      strFile = rndfile
      xlWorksheet.SaveAs Server.MapPath(strFile & ".xls")
      xlApplication.Quit
      'Close the Workbook
      Set xlWorksheet = Nothing
      Set xlApplication = Nothing
      response.Redirect(strFile & ".xls")
    end if

    %>

  • 相关阅读:
    python学习-装饰器
    python-内置函数
    HA高可用解决方案-RHCS部署
    mac安装nose,command not found:nosetests
    iPhone的home键进果汁了,按起来粘粘的感觉
    Reportng 的测试报告在 Jenkins 中显示不全
    atom markdown报错:AssertionError: html-pdf: Failed to load PhantomJS module.
    markdown的图片外链
    reportng定制修改
    运行maven build报错No goals have been specified for this build.
  • 原文地址:https://www.cnblogs.com/xffy1028/p/2344342.html
Copyright © 2020-2023  润新知