« HTML元素的默认CSS设置IE5/IE5.5/IE6/Firefox 中css表现的差异 »

用ASP输出Word、Excel文件

<%

Dim Fso,FileExt,strFilePath,Mime
strFilePath = "f:\sifang\qyoa\国贸手抄.doc"
Set Fso=Server.CreateObject("Scripting.FileSystemObject")
FileExt = Fso.GetExtensionName(strFilePath)
Set fso=Nothing

Select Case FileExt
Case "doc"
Mime="Application/msword"
Case "xls"
Mime="Application/msexcel"
End Select

Call OutPut(strFilePath,Mime)

'######################################################
Function OutPut(strFilePath,Mime)
Response.ContentType = Mime
Const adTypeBinary = 1
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
Response.BinaryWrite objStream.Read
objStream.Close
Set objStream = Nothing
End Function
'######################################################
%>
原创文章如转载,请注明:转载自悠悠博客 [ http://www.ajaxstu.com/ ]

相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。