Thinking & Sharing

Watch Exchange Imagine Negate Innovate Express
ASP向浏览器写入一个 Excel 文件

From MSDN:

<%
'Set the content type to the specific type that you are sending.
Response.ContentType = "application/x-msexcel"

Const adTypeBinary = 1
Dim strFilePath

strFilePath = "C:\ExcelFiles\Excel1.xls" 'This is the path to the file on disk.

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath

Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
%>
 

posted on 2008-11-08 10:52  weinie  阅读(258)  评论(0)    收藏  举报