亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    asp讀取數(shù)據(jù)庫數(shù)據(jù)并生成excel文件實(shí)例

    asp讀取數(shù)據(jù)庫數(shù)據(jù)并生成excel文件實(shí)例
    代碼如下:

    <HTML>
    <HEAD>
    <meta content=”text/html; charset=gb2312″ http-equiv=”Content-Type”>
    <TITLE>生成EXCEL文件實(shí)例</TITLE>
    </HEAD>
    <body>
    <a href=”dbtoexcel.asp?act=make”>在線生成EXCEL</a>
    <hr size=1 align=left width=300px>
    <%
    if Request(“act”) = “” then
    Response.Write “生成EXCEL文件實(shí)例”
    else
    dim conn,strconn
    strconn=”driver={SQL Server};server=wen;uid=sa;pwd=;database=DB_Test”
    set conn=server.CreateObject(“adodb.connection”)
    conn.Open strconn
    dim rs,sql,filename,fs,myfile,x
    Set fs = server.CreateObject(“scripting.filesystemobject”)
    ‘–假設(shè)你想讓生成的EXCEL文件做如下的存放
    filename = Server.MapPath(“online.xls”)
    ‘–如果原來的EXCEL文件存在的話就刪除
    if fs.FileExists(filename) then
    fs.DeleteFile(filename)
    end if
    ‘–創(chuàng)建EXCEL文件
    set myfile = fs.CreateTextFile(filename,true)
    Set rs = Server.CreateObject(“ADODB.Recordset”)
    ‘–從數(shù)據(jù)庫中把你想放到EXCEL中的數(shù)據(jù)讀出來
    sql = “select * from Tb_Execl order by id desc”
    rs.Open sql,conn,1,1

    if rs.EOF and rs.BOF then
    else
    dim strLine,responsestr
    strLine=””
    For each x in rs.fields
    strLine = strLine & x.name & chr(9)
    Next
    ‘–將表的列名先寫入EXCEL
    myfile.writeline strLine
    Do while Not rs.EOF
    strLine=””
    for each x in rs.Fields
    strLine = strLine & x.value & chr(9)
    next
    ‘–將表的數(shù)據(jù)寫入EXCEL
    myfile.writeline strLine
    rs.MoveNext
    loop
    end if
    rs.Close
    set rs = nothing
    End If
    %>

     

    分享到: 更多

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號