1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> 
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  3. <html xmlns="http://www.w3.org/1999/xhtml"> 
  4. <head> 
  5. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  6. <title><%=SiteTitle%></title> 
  7. <meta name="keywords" content="<%=SiteTitle%>" /> 
  8. <meta name="description" content="<%=SiteTitle%>" /> 
  9. </head> 
  10. <body> 
  11. <% '以下实例中excel文件名为:list.xls,工作表名为:sheet1  
  12.       Dim conn 
  13.       Dim StrConn 
  14.       Dim rs 
  15.       Dim Sql 
  16.       Set conn=Server.CreateObject("ADODB.Connection")  
  17.       'StrConn="Driver={Microsoft Excel Driver (*.xls)};DBQ="& Server.MapPath("list.xls") 
  18.    StrConn="Driver={Microsoft Excel Driver (*.xls)};DBQ="& Server.MapPath("list.xls") 
  19.       conn.Open StrConn 
  20.       Set rs = Server.CreateObject("ADODB.Recordset")  
  21.       Sql="select * from [Sheet1$]" 
  22.       rs.Open Sql,conn,2,2  
  23.       %> 
  24.       <center> 
  25.       <table border="0" cellpadding="0" cellspacing="0"> 
  26.       <tr> 
  27.       <
  28.       for i=0 to rs.Fields.Count-1 
  29.       %> 
  30.       <td width="1" bgcolor="#CCCCCC"></td> 
  31.       <td height="28" bgcolor="#0099FF"><div align="center"><%=rs(i).Name%></div></td> 
  32.       <
  33.       next 
  34.       %> 
  35.       <td width="1" bgcolor="#CCCCCC"></td> 
  36.       </tr> 
  37.       <
  38.       do while Not rs.EOF 
  39.           %> 
  40.           <tr> 
  41.           <
  42.           for i=0 to rs.Fields.Count-1 
  43.           %> 
  44.           <td width="1" bgcolor="#CCCCCC"></td> 
  45.           <td height="28" valign="bottom"><%=rs(i)%></td> 
  46.           <
  47.           next 
  48.           %> 
  49.           <td width="1" bgcolor="#CCCCCC"></td> 
  50.           </tr> 
  51.           <tr> 
  52.           <%'生成高度为1的空行(横线) 
  53.           for i=0 to rs.Fields.Count-1 
  54.           %> 
  55.           <td height="1" bgcolor="#CCCCCC"></td> 
  56.           <td height="1" bgcolor="#CCCCCC"></td> 
  57.           <
  58.           next 
  59.           %> 
  60.           <td width="1" bgcolor="#CCCCCC"></td> 
  61.           </tr> 
  62.           <
  63.       rs.MoveNext 
  64.       Loop 
  65.       rs.close 
  66.       set rs=nothing 
  67.       Conn.close 
  68.       set StrConn=nothing 
  69.       %> 
  70.       </table> 
  71.       </center> 
  72. </body> 
  73. </html>