专注网页设计制作教程: http://www.update8.com

如何把access数据导出excel数据代码

时间:2010-05-26 09:14点击: 次 【

如何把access数据导出excel数据代码

<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=gb2312">
    </head>
   
    <body>
        <table border="1" cellspacing="1" cellpadding="1">
            <tr bgcolor="#999933">
                <td><div align="center"><strong>部门</strong></div></td>
                <td><div align="center"><strong>工号</strong></div></td>
                <td><div align="center"><strong>姓名</strong></div></td>
                <td><div align="center"><strong>培训号</strong></div></td>
                <td><div align="center"><strong>培训内容</strong></div></td>
                <td><div align="center"><strong>培训类别</strong></div></td>
                <td><div align="center"><strong>开始日期</strong></div></td>
                <td><div align="center"><strong>结束日期</strong></div></td>
                <td><div align="center"><strong>学时</strong></div></td>
                <td><div align="center"><strong>学分</strong></div></td>
                <%
                response.write"<td><div align='center'><strong>"&coursedept&"</strong></div></td>"
                response.write"<td><div align='center'><strong>"&strsql&"</strong></div></td>"
                %>
               
            </tr>
            <%
                If Not result.eof then
                Do While Not result.eof
            %>
            <tr>
                <td><%=result("memberdept")%></td>
                <td><%=result("m.memberid")%></td>
                <td><%=result("membername")%></td>
                <td><%=result("c.courseid")%></td>
                <td><%=result("coursename")%></td>
                <td><%=result("coursetype")%></td>
                <td><%=result("coursebegindate")%></td>
                <td><%=result("courseenddate")%></td>
                <td><%=result("courseperiod")%></td>
                <td><%=result("coursescore")%></td>
            </tr>
      
      <%
                result.movenext
                loop
                End if
                result.close
                Set result=nothing
                conn.close
                Set conn=Nothing
            %>


    
  </table>
  </body>
  </html>
 

  <%
  if request.Form("coursedept") then
        coursedept=request.form("coursedept")
        coursetype=request.form("coursetype")
        coursebegindate=request.form("coursebegindate")
        courseenddate=request.form("courseenddate")
        db="xf.mdb"
        teacher="老师"
       
       
        strsql="select * from XF_Member m, XF_Course c, XF_Score s where (s.courseid=c.courseid) and (s.memberid=m.memberid) and (s.membertype='"&teacher&"') "
        If coursedept<>"" Then
        strsql=strsql&" and (c.coursedept='"&coursedept&"')"
        End If
        Set conn = Server.CreateObject("ADODB.Connection")
        connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
        conn.Open connstr
       
        Set result=conn.execute(strsql)
       
        response.ContentType="application/vnd.ms-excel"
        'response.write "strsql:"+strsql+"dept:"+coursedept
  end if       
        %>
------分隔线----------------------------