How to export Access data to Excel data code

Source: Internet
Author: User



<meta http-equiv= "Content-type" content= "text/html;charset=gb2312" >


<body>
<table border= "1" cellspacing= "1" cellpadding= "1" >
<tr bgcolor= "#999933" >
<td><div align= "Center" ><strong> Department </strong></div></td>
<td><div align= "center" ><strong> work number </strong></div></td>
<td><div align= "center" ><strong> name </strong></div></td>
<td><div align= "Center" ><strong> Training number </strong></div></td>
<td><div align= "Center" ><strong> Training content </strong></div></td>
<td><div align= "Center" ><strong> Training category </strong></div></td>
<td><div align= "center" ><strong> Start date </strong></div></td>
<td><div align= "center" ><strong> End date </strong></div></td>
<td><div align= "center" ><strong> Hours </strong></div></td>
<td><div align= "center" ><strong> credits </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 as 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>

<%
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= "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



%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.