zoukankan      html  css  js  c++  java
  • 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

    %>

  • 相关阅读:
    Spark Sort-Based Shuffle具体实现内幕和源码详解
    Spark-2.0原理分析-shuffle过程
    Spark Shuffle 中 JVM 内存使用及配置内幕详情
    Spark中的Spark Shuffle详解
    Spark Shuffle Write阶段磁盘文件分析
    Spark Sort Based Shuffle内存分析
    Spark Storage(二) 集群下的broadcast
    Spark SQL metaData配置到Mysql
    TweenJS----前端常用的js动画库,缓动画和复制动画的制作,效果非常好。
    Storm入门
  • 原文地址:https://www.cnblogs.com/xffy1028/p/2344342.html
Copyright © 2011-2022 走看看