Récemment, j'ai étudié comment appeler Doc avec une page Web. . Utiliser Doc pour lire et afficher les données binaires.
Programme ASP:
<%
réponse.buffer = true
Response.ContentType = Application / X-MSexcel
dimvntsstream
setMyObject = Server.CreateObject (myObject.BinRead) 'Ce composant est introduit plus tard
vTSstream = omyObject.readbinfile (c: /temp/tempxls.xls)
réponse.binarywrite (VNTstream)
setMyObject. pas
réponse.
%>
Code de contrôle:
Étape 1: Créez un activexdllproject dans vb
Étape 2: Modifiez le nom du projet en myObject
Étape 3: Renommer la classe pour binread
Étape 4: Écrivez le code suivant dans le module de classe
FunctionReadBinfile (byValBFilenameSsString)
Dimfaslong
Dimfilenumasbyte
Dimbinbyte () asstring
Filenum = fichier libre
OpenBFileNameForbinaryAccessReadas # Filenum
fl = filelen (bfilename)
Redimbinbyte (FL)
Obtenez # filenum, binbyte
Fermer # filenum
readbinfile = binbyte
Finition de fin
Étape 5: Enregistrer
Étape 6: compilation
Mon code, pour une raison quelconque, ne peut pas être ouvert en ligne:
<%
Réponse.buffer = true
réponse.ContentType = application / msword
server.execute (111.doc)
%>
Ci-joint:
ASP: Response.ContentType Liste détaillée
Différents contenus affecteront l'effet observé par le client.
Des codes tels que:
<% Response.ContentType = Text / HTML%>
<! - # inclusVirtual = / contentType.html ->
La page s'affiche, et
<% Response.ContentType = Text / Plain%>
<! - # inclueVirtual = / Script / ContentType.html ->
Le code HTML d'origine sera affiché.
Voici quelques types de contenu couramment utilisés
Gifiimages
<% Response.ContentType = Image / GIF%>
<! - # inclusVirtual = / myimage.gif ->
Jpegimages
<% Response.ContentType = Image / JPEG%>
<! - # inclusVirtual = / myimage.jpeg ->
Tiffiimages
<% Response.ContentType = Image / Tiff%>
<! - # inclusVirtual = / myimage.tiff ->
MicrosoftwordDocument
<% réponse.contentType = application / msword%>
<! - # inclusVirtual = / myfile.doc ->
RTFDocument
<% Response.ContentType = Application / RTF%>
<! - # inclusVirtual = / myfile.rtf ->
MicrosoftexcelDocument
<% réponse.contentType = application / x-excel%>
<! - # inclueVirtual = / myFile.xls ->
MicrosoftpowerPointDocument
<% Response.ContentType = Application / MS-PowerPoint%>
<! - # inclusVirtual = / myfile.pff ->
Pdfocument
<% Response.ContentType = Application / PDF%>
<! - # inclusVirtual = / myfile.pdf ->
Zipcument
<% Response.ContentType = Application / Zip%>
<! - # inclusVirtual = / myfile.zip ->
Vous trouverez ci-dessous un contenu plus détaillé
'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 / octtet-stream',
'lzh' => 'application / octtet-stream',
'exe' => 'Application / Octet-Stream',
'class' => 'application / octtet-stream',
'SO' => 'Application / Octet-Stream',
'dll' => 'application / octtet-stream',
'oda' => 'application / oda',
'pdf' => 'application / pdf',
'ai' => 'Application / PostScript',
'eps' => 'Application / PostScript',
'ps' => 'application / post-scriptum',
'smi' => 'application / smil',
'smil' => 'application / smil',
'mif' => 'application / vnd.mif',
'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-Director',
'dir' => 'Application / X-Director',
'dxr' => 'Application / X-Director',
'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',
'TexInfo' => 'Application / X-Texinfo',
'Texi' => 'Application / X-Texinfo',
't' => 'application / x-troff',
'tr' => 'application / x-troff',
'roff' => 'application / x-troff',
'man' => 'application / x-troff-man',
'moi' => 'application / x-troff-me',
'ms' => 'application / x-troff-ms',
'usstar' => 'application / x-usstar',
'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',
'ra' => 'Audio / X-Realaudio',
'wav' => 'audio / x-wav',
'pdb' => 'chimique / x-pdb',
'xyz' => 'chimique / 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',
'igs' => 'modèle / iges',
'igès' => 'modèle / igités',
'Msh' => 'Modèle / Mesh',
'Mesh' => 'Modèle / Mesh',
'Silo' => 'Modèle / Mesh',
'wrl' => 'modèle / vrml',
'vrml' => 'modèle / vrml',
'css' => 'text / css',
'html' => 'text / html',
'htm' => 'text / html',
'ASC' => 'Texte / 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' => 'vidéo / mpeg',
'mpg' => 'vidéo / mpeg',
'mpe' => 'vidéo / mpeg',
'qt' => 'vidéo / Quicktime',
'mov' => 'Vidéo / Quicktime',
'mxu' => 'vidéo / vnd.mpegurl',
'avi' => 'vidéo / x-msvideo',
'film' => 'vidéo / x-sgi-movie',
'glace' => 'x-conférence / x-cooltalk'