Microsoft has an article: Workshop
Asp program:
<%
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
%>
Control Code:
Step 1: Create an ActiveX DLL Project in VB
Step 2: Change the project name to MyObject
Step 3: Rename the class to BinRead
Step 4: Write the following code in the class module:
Function readBinFile (ByVal bfilename As String)
Dim fl As Long
Dim FileNum As Byte
Dim binbyte () As String
FileNum = FreeFile
Open bfilename For Binary Access Read As # FileNum
Fl = FileLen (bfilename)
ReDim binbyte (fl)
Get # FileNum, binbyte
Close # FileNum
ReadBinFile = binbyte
End Function
Step 5: Save Disks
Step 6: Compile
My code, somehow saved, cannot be opened online:
<%
Response. Buffer = TRUE
Response. ContentType = "application/msword"
Server. Execute ("111.doc ")
%>
Appendix:
ASP: Response. ContentType detailed list
Different contenttypes will affect the client's effect. The default ContentType is text/html, that is, the webpage format.
The Code is as follows:
<% Response. ContentType = "text/html" %>
<! -- # I nclude virtual = "/ContentType.html" -->
Is displayed as a Web page, while
<% Response. ContentType = "text/plain" %>
<! -- # I nclude virtual = "/sscript/ContentType.html" -->
The original html code is displayed.
The following are some common contenttypes:
GIF images
<% Response. ContentType = "image/gif" %>
<! -- # I nclude virtual = "/myimage.gif" -->
JPEG images
<% Response. ContentType = "image/jpeg" %>
<! -- # I nclude virtual = "/myimage.jpeg" -->
TIFF images
<% Response. ContentType = "image/tiff" %>
<! -- # I nclude virtual = "/myimage. tiff" -->
Microsoft word document
<% Response. ContentType = "application/msword" %>
<! -- # I nclude virtual = "/myfile.doc" -->
RTF document
<% Response. ContentType = "application/rtf" %>
<! -- # I nclude virtual = "/myfile. rtf" -->
Microsoft excel document
<% Response. ContentType = "application/x-excel" %>
<! -- # I nclude virtual = "/myfile.xls" -->
Microsoft powerpoint document
<% Response. ContentType = "application/ms-powerpoint" %>
<! -- # I nclude virtual = "/myfile. pff" -->
PDF document
<% Response. ContentType = "application/pdf" %>
<! -- # I nclude virtual = "/myfileprohibited" -->
ZIP document
<% Response. ContentType = "application/zip" %>
<! -- # I nclude virtual = "/myfile.zip" -->
Below is a more detailed ContentType
'Ez '=> 'application/andrew-inset ',
'Hqx' => 'application/mac-binhex40 ',
'Cpt' => 'application/mac-compactpro ',
'Doc' => 'application/msword ',
'Bin' => 'application/octet-stream ',
'Dms '=> 'application/octet-stream ',
'Lha' => 'application/octet-stream ',
'Lzh '=> 'application/octet-stream ',
'Exe '=> 'application/octet-stream ',
'Class' => 'application/octet-stream ',
'So' => 'application/octet-stream ',
'Dll '=> 'application/octet-stream ',
'Oda '=> 'application/oda ',
'Pdf '=> 'application/pdf ',
'Ai' => 'application/postscript ',
'Eps '=> 'application/postscript ',
'Ps '=> 'application/postscript ',
'Smi' => 'application/smil ',
'Smil '=> 'application/smil ',
'Mfa' => 'application/vnd. mfa ',
'Xls '=> 'application/vnd. ms-excel ',
'Ppt '=> 'application/vnd. ms-powerpoint ',
'Wbxml' => 'application/vnd. wap. wbxml ',
'Wmlc' => 'application/vnd. wap. wmlc ',
'Wmlsc '=> 'application/vnd. wap. wmlscriptc ',
'Bcpio' => 'application/x-bcpio ',
'Vcd' => 'application/x-cdlink ',
'Pgn' => 'application/x-chess-pgn ',
'Cpio' => 'application/x-cpio ',
'Csh' => 'application/x-csh ',
'Dcr '=> 'application/x-ctor ',
'Dir' => 'application/x-ctor ',
'Dxr' => 'application/x-ctor ',
'Dvi '=> 'application/x-dvi ',
'Spl' => 'application/x-futuresplash ',
'Gtar '=> 'application/x-gtar ',
'Hdf' => 'application/x-hdf ',
'Js' => 'application/x-javascript ',
'Skp' => 'application/x-koan ',
'Skd' => 'application/x-koan ',
'Skt' => 'application/x-koan ',
'Skm' => 'application/x-koan ',
'Latex '=> 'application/x-latex ',
'Nc '=> 'application/x-netcdf ',
'Cdf' => 'application/x-netcdf ',
'Sh' => 'application/x-Sh ',
'Shar '=> 'application/x-shar ',
'Swf '=> 'application/x-shockwave-flash ',
'Sit '=> 'application/x-stuffit ',
'Sv4cpio '=> 'application/x-sv4cpio ',
'Sv4crc '=> 'application/x-sv4crc ',
'Tar '=> 'application/x-tar ',
'Tcl '=> 'application/x-tcl ',
'Tex '=> 'application/x-tex ',
'Textinfo' => 'application/x-textinfo ',
'Text' => 'application/x-textinfo ',
'T' => 'application/x-troff ',
'Tr' => 'application/x-troff ',
'Roff' => 'application/x-troff ',
'Man '=> 'application/x-troff-man ',
'Me' => 'application/x-troff-me ',
'Ms' => 'application/x-troff-Ms ',
'Ustar' => 'application/x-ustar ',
'Src' => 'application/x-wais-source ',
'Xhtml '=> 'application/xhtml + xml ',
'Xht '=> 'application/xhtml + xml ',
'Zip' => 'application/zip ',
'Au '=> 'audio/basic ',
'Snd' => 'audio/basic ',
'Mid '=> 'audio/midi ',
'Midi '=> 'audio/midi ',
'Kar '=> 'audio/midi ',
'Mpga' => 'audio/mpeg ',
'Mp2' => 'audio/mpeg ',
'Mp3' => 'audio/mpeg ',
'Aif' => 'audio/x-aiff ',
'Aiff '=> 'audio/x-aiff ',
'Aifc '=> 'audio/x-aiff ',
'M3u' => 'audio/x-mpegurl ',
'Ram '=> 'audio/x-pn-realaudio ',
'Rm '=> 'audio/x-pn-realaudio ',
'Rpm '=> 'audio/x-pn-realaudio-plugin ',
'A' => 'audio/x-realaudio ',
'Wav '=> 'audio/x-wav ',
'Pdb' => 'chemical/x-pdb ',
'Xyz' => 'chemical/x-xyz ',
'Bmp '=> 'image/bmp ',
'Gif' => 'image/gif ',
'Ief' => 'image/ief ',
'Jpeg '=> 'image/jpeg ',
'Jpg '=> 'image/jpeg ',
'Jpe' => 'image/jpeg ',
'Png '=> 'image/png ',
'Tiff '=> 'image/tiff ',
'Tif '=> 'image/tiff ',
'Djvu '=> 'image/vnd. djvu ',
'Djv' => 'image/vnd. djvu ',
'Wbmp '=> 'image/vnd. wap. wbmp ',
'Ras '=> 'image/x-cmu-raster ',
'Pnm '=> 'image/x-portable-anymap ',
'Pbm' => 'image/x-portable-bitmap ',
'Pgm '=> 'image/x-portable-graymap ',
'Ppm '=> 'image/x-portable-pixmap ',
'Rgb '=> 'image/x-rgb ',
'Xbm '=> 'image/x-xbitmap ',
'Xpm' => 'image/x-xpixmap ',
'Xwd '=> 'image/x-xwindowdump ',
'Gies' => 'model/iges ',
& Apos; iges & apos; = & apos; model/iges & apos ',
'Msh' => 'model/mesh ',
'Mesh '=> 'model/mesh ',
'Silo' => 'model/mesh ',
'Wrl' => 'model/jpa ',
'Jpa' => 'model/jpa ',
'Css '=> 'text/css ',
'Html' => 'text/html ',
'Htm '=> 'text/html ',
'Asc '=> 'text/plain ',
'Txt '=> 'text/plain ',
'Rtx' => 'text/richtext ',
'Rtf '=> 'text/rtf ',
'Sgml' => 'text/sgml ',
'Sgm' => 'text/sgml ',
'Tsv' => 'text/tab-separated-values ',
'Wml' => 'text/vnd. wap. wml ',
'Wmls' => 'text/vnd. wap. wmlscript ',
'Etx' => 'text/x-setext ',
'Xsl '=> 'text/xml ',
'Xml' => 'text/xml ',
'Mpeg '=> 'video/mpeg ',
'Mpg' => 'video/mpeg ',
'Mpe' => 'video/mpeg ',
'Qt '=> 'video/quicktime ',
'Mov' => 'video/quicktime ',
'Mxu' => 'video/vnd. mpegurl ',
'Av' => 'video/x-msvideo ',
'Movi' => 'video/x-sgi-movi ',
'Ice '=> 'x-conference/x-cooltalk'