Open Word/Excel file

S

Simon Cheng

Hi,

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

Thanks,
Simon
 
M

Mark Rae

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

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?
 
R

Rick Strahl [MVP]

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top