数据库资料生成excel

来源:互联网 发布:喊麦变声软件 编辑:程序博客网 时间:2024/06/05 14:22


<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><%

'//数据库链接set conn=server.CreateObject("adodb.connection")DBPath = Server.MapPath("excel.mdb")conn.open "provider=microsoft.jet.oledb.4.0; data source="&DBpath%><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>无标题文档</title><style type="text/css"><!--body,td,th { font-size: 12px;}--></style></head>

<body><%response.ContentType="application/vnd.ms-excel"%><%set rs=conn.execute("select * from guestbook")%><table   border="1" cellspacing="0">  <tr>  <%  j=2  for i=0 to rs.fields.count-1  %>    <td width="50" align="center" bgcolor="#FFFFCC"><%=rs.fields(i).name%></td>   <%next%>

  </tr>  <%do while not rs.eof%>  <tr>  <%for i=0 to rs.fields.count-1%>    <td align="center" ><%=rs(i)%></td> <%next%>

  </tr>  <%  rs.movenext  j=j+1  loop  rs.close  %></table></body></html> 

原创粉丝点击