Lm th? no ? ?c v hi?n th? d? li?u nh? phn trong ASP

D?ch tiu ? D?ch tiu ?
ID c?a bi: 193998 - 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

Bi vi?t ny cho th?y lm th? no ? ?c v hi?n th? d? li?u nh? phn b?ng cch s? d?ng my ch? ang ho?t ?ng Cc trang.

Cc nh pht tri?n nhi?u nh gi cao s? d? dng c?a vi?c s? d?ng Scripting.FileSystemObject ? m? m?t t?p tin ASCII v sau hi?n th? n?i dung c?a n trong Microsoft Word ho?c Microsoft Excel t? trong Internet Explorer. Trong khi ra ?i hi?n t?i, ASP khng tr?c ti?p cung c?p b?t k? v?t th? so snh ? ?c t?p tin ch?a d? li?u nh? phn nh m?t b?ng tnh Excel v?i macro, m?t Adobe T?p tin Acrobat (.pdf), m?t .gif, ho?c b?t k? cc t?p tin ch?a nh? phn d? li?u. Tuy nhin, m?t nh pht tri?n ASP c th? vi?t m?t ?i t?ng ty ch?nh kinh doanh ho?c thnh ph?n m thm ch?c nng ny.

THNG TIN THM

Ph?n ti cung c?p m? ASP nh?n ?c v sau hi?n th? nh? phn t?p tin b?ng cch s? d?ng m?t thch h?p MIME lo?i, v m?t ph?n II cho th?y lm th? no ? t?o ra cc Visual Basic 5,0 (ho?c sau ny) ActiveX DLL ph?n ko di cc kh? nng c?a ASP ? ?c d? li?u nh? phn.

Ph?n I: ASP m?u m s? m? ra m?t b?ng tnh Excel c ch?a macro

   <%
   Response.buffer = TRUE
   Response.ContentType = "application/x-msexcel"

   Dim vntStream

   Set oMyObject = Server.CreateObject("MyObject.BinRead")
   vntStream = oMyObject.readBinFile("c:\temp\tempxls.xls")

   Response.BinaryWrite(vntStream)

   Set oMyObject = Nothing

   Response.End
   %>
				

LU ?: ?i v?i t?p tin Acrobat, thay ?i ki?u MIME b?ng cch s? d?ng Response.ContentType = "?ng d?ng/pdf". ?i v?i m?t h?nh ?nh .gif, s? d?ng Response.ContentType = "h?nh ?nh/gif".

Ph?n II: Visual Basic 5.0 ActiveX DLL (MyObject.BinRead)

? t?o ra cc thnh ph?n th?c hi?n i ?c, th?c hi?n cc b?c sau:
  1. T?o m?t d? n ActiveX DLL m?i Visual Basic 5.0 ho?c sau .
  2. ?i tn d? n MyObject.
  3. ?i tn l?p m-un BinRead.
  4. C?t v dn o?n m? sau vo ph?n khai bo chung L?p Module:
       Function readBinFile(ByVal bfilename As String) As Variant
              Dim fl As Long
              Dim FileNum As Long
              Dim binbyte() As Byte
              Dim binfilestr As String
    
              On Error GoTo errHandler
              
              FileNum = FreeFile
              Open bfilename For Binary Access Read As #FileNum
    
              fl = FileLen(bfilename)
              ReDim binbyte(fl)
    
              Get #FileNum, , binbyte
    
              Close #FileNum
    
              readBinFile = binbyte
              Exit Function
    
          errHandler:
              Exit Function
          End Function
    						
  5. Lu d? n.
  6. Trn menu T?p, b?m vo lm cho MyObject.dll.
N?u my ch? Web c?a b?n l trn my ring bi?t t? ni m b?n ? t?o cc thnh ph?n, b?n c?n ph?i sao chp cc thnh ph?n vo my ch? Web v ng k? n s? d?ng RegSvr32.

? k?t h?p cc t?p tin t?o m?t ph?n ti vo m?t trang ASP c vn b?n ho?c ?nh d?ng khc, s? d?ng m?t pha my ch? bao g?m tuyn b?.

Thu?c tnh

ID c?a bi: 193998 - L?n xem xt sau cng: 20 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • Microsoft Active Server Pages 4.0
T? kha:
kbcode kbfso kbhowto kbscript kbmt KB193998 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:193998

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