Lm th? no ? hi?n th? ASP k?t qu? b?ng cch s? d?ng Excel trong IE v?i MIME Types

D?ch tiu ? D?ch tiu ?
ID c?a bi: 199841 - Xem s?n ph?m m bi ny p d?ng vo.
Bung t?t c? | Thu g?n t?t c?

? Trang ny

TM T?T

Thay v? c?a hi?n th? d? li?u trang Web c?a b?n trong b?ng HTML, b?n c th? cung c?p cho ng?i s? d?ng ty ch?n hi?n th? cc d? li?u trong Microsoft Excel. i?u ny bi vi?t ch?ng t? lm th? no ? t?o m?t trang Web v?i b?ng d? li?u thu ?c t? Microsoft SQL Server, v a ra n trong Excel bn trong tr?nh duy?t c?a lin k?t m n?i dung trang Web v?i ki?u MIME trong Excel.

THNG TIN THM

Lm theo cng v?i cc b?c v ? ki?m tra k?t qu?, b?n c?n nh?ng i?u sau y:
  • Microsoft Windows NT Server 4.0, SP3
  • Microsoft Internet Information Server (IIS), phin b?n 4.0 ho?c sau ny
  • Microsoft SQL Server 6,5 ho?c m?i hn
  • Microsoft Excel 97, Excel 2000 v Excel 2002

T?ng b?c th? t?c

  1. T?o m?t DSN h? th?ng ?c g?i l "qun r?u" b?ng cch s? d?ng ODBC Ti?u d?ng b?ng i?u khi?n. Thi?t l?p DSN ? tham kh?o c?a b?n my ch? SQL ?a phng, s? d?ng SQL Server xc th?c, v s? d?ng "qun r?u" nh l c s? d? li?u m?c ?nh. M?c ?nh ng nh?p ID ? c s? d? li?u qun r?u l sa, v?i khng c m?t kh?u.
  2. S? d?ng Notepad.exe ? t?o ra m?t t?p tin g?i l XlTest.asp c?a b?n IIS Trang ch? th m?c (v d?, inetpub\wwwroot), v thm sau y ? n:
    <%@ Language=VBScript %>
    <%
       'Change HTML header to specify Excel's MIME content type
       Response.Buffer = TRUE
       Response.ContentType = "application/vnd.ms-excel"
    %>
    <HTML>
    <BODY>
    Here is the info you requested.<p>
    <%
       ' Create ADO Connection object
       dim myConnection
       set myConnection = CreateObject("ADODB.Connection")
       
       ' Open SQL Server Pubs database...
       ' myConnection.Open "DSN=pubs;UID=sa"
       
       ' Get a recordset of info from Authors table...
       sqlStr = "SELECT au_fname,au_lname,phone FROM authors"
       set rsAuthors =  myConnection.Execute(sqlStr)
    %>
    
    <!-- Our table which will be translated into an Excel spreadsheet -->
    <TABLE WIDTH=75% BORDER=1 CELLSPACING=1 CELLPADDING=1>
    <TR>
       <TD><font size=+2>First Name</font></TD>
       <TD><font size=+2>Last Name</font></TD>
       <TD><font size=+2>Phone</font></TD>
    </TR>
    <!-- server-side loop adding Table entries -->
    <% do while not rsAuthors.EOF %>
    <TR>
       <TD><%=rsAuthors("au_fname")%></TD>
       <TD><%=rsAuthors("au_lname")%></TD>
       <TD><%=rsAuthors("phone")%></TD>
    </TR>
    <% rsAuthors.MoveNext
       loop
       ' Clean up
       rsAuthors.Close
       set rsAuthors = Nothing
       myConnection.Close
       set myConnection = Nothing
    %>
    </TABLE>
    </BODY>
    </HTML>
    						
  3. Lu XlTest.asp, v sau xem n t? m?t tr?nh duy?t c?a khch hng. V d?, http://MyServer/XlTest.asp (thay th? MyServer v?i tn c?a my ch? c?a b?n.)
N?u Microsoft Excel 97 ?c ci ?t trn my khch, Microsoft Excel s? hi?n th? cc d? li?u bn trong tr?nh duy?t.

Thu?c tnh

ID c?a bi: 199841 - L?n xem xt sau cng: 20 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft Visual InterDev 6.0 Standard Edition
  • Microsoft Internet Information Services 5.0
  • Microsoft Excel 97 Standard Edition
  • Microsoft Excel 2000 Standard Edition
  • Microsoft Excel 2002 Standard Edition
T? kha:
kbhowto kbmt KB199841 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:199841

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com