Groups | Blog | Home
all groups > asp.net > february 2005 >

asp.net : Open Word/Excel file


Simon Cheng
2/13/2005 11:03:15 PM
Hi,

How do I open a Word or Excel document inside an event handler (e.g.,
Page_Load())?

Thanks,
Simon

Simon Cheng
2/13/2005 11:46:49 PM
It is intended to be shown to the end user as a read-only document.

[quoted text, click to view]

Steve C. Orr [MVP, MCSD]
2/14/2005 12:17:10 AM
Response.Redirect("SomeFile.doc");

If that's too simplistic for you then look into Response.WriteFile.

Here's more info:
http://SteveOrr.net/Articles/EasyUploads.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


[quoted text, click to view]

Rick Strahl [MVP]
2/14/2005 1:43:41 AM
In that case just return the document in the HTTP stream. You can open a
file stream to the Word document and the stream it into
Response.OutputStream. You should set hte content type to:
"application/msword".

Actually if the file lives on disk the following is the most efficient way
to get data back to the client:

Response.ContentType = "application/msword";
Response.TransmitFile(@"d:\articles\blog.doc");
Response.End();
Otherwise you have have to stream into Response.OutputStream().

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
http://www.west-wind.com/wwThreads/
----------------------------------
Making waves on the Web


[quoted text, click to view]

Mark Rae
2/14/2005 7:33:49 AM
[quoted text, click to view]

Depends where you want to open it. Do you want to open it server-side so you
can do some processing on it, or do want to open it client-side so that the
user can view / edit it?

AddThis Social Bookmark Button