如何把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
%>