How can I embed images in an ASP.NET Generated Word File

Posted by Nikos Steiakakis on Stack Overflow See other posts from Stack Overflow or by Nikos Steiakakis
Published on 2008-12-12T10:20:24Z Indexed on 2010/04/08 6:13 UTC
Read the original article Hit count: 320

Filed under:
|
|

Hi everyone!

I have a quite common problem, as I saw in the various user groups but could not find a suitable answer.

What I want to do is generate an ASP.NET page in my website which will have the option of being exported into Microsoft Word .doc format.

The method I have used is this:

Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=Test.doc");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/msword";

StringWriter sw = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(sw);
Page.RenderControl(htmlWrite);
Response.Write(sw.ToString());
Response.End();

However this eventhough it generates a word doc, the images are note embedded in the document, rather they are placed as links. I have looked for a way to do this, but have not found something that actually worked.

I would appreciate any help I can get, since this as "last minute" requirement (talk about typical)

Thanks

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about msword