鉴于大家对ASP十分关注,我们编辑小组在此为大家搜集整理了“用asp实现网页调用doc附Response.ContentType 详细列表”一文,供大家参考学习
微软有篇文章:http://support.microsoft.com/kb/193998/zh-cn,用doc读取和显示二进制数据,《怎样读取二进制文件》,没测试,懒得编译dll
asp
程序:
<%
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
%>
控件代码:
第一步:在VB中创建一个ActiveX DLL Project
第二步:把工程名改为MyObject
第三步:把class更名为BinRead
第四步:在class模块中写上以下代码
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
第五步:存盘
第六步:编译
我的代码,不知为什么可以保存,在线打不开:
<%
Response.Buffer = TRUE
response.ContentType="application/msword"
server.Execute("111.doc")
%>
附:
ASP:Response.ContentType 详细列表
不同的ContentType 会影响客户端所看到的效果.默认的ContentType为 text/html 也就是网页格式.
代码如:
<% response.ContentType ="text/html" %>
<!--#i nclude virtual="/ContentType.html" -->
显示的为网页,而
<% response.ContentType ="text/plain" %>
<!--#i nclude virtual="/sscript/ContentType.html" -->
则会显示html原代码.
以下为一些常用的 ContentType
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="/myfile.pdf" -->
ZIP document
<% response.ContentType ="application/zip" %>
<!--#i nclude virtual="/myfile.zip" -->
下面是更详细的ContentType
''ez'' => ''application/andrew-inset'',
''hqx'' => ''application/mac-binhex40'',
''cpt'' => ''application/ma