Home  »  Code Snippets  »  C#.Net  »

Export webpage as word document using asp.net and c#.net

 Posted By : Manoranjan SahooPosted Date : 13/05/2011 06:04:06 AM Category : C#.Net Points : 4

Sometimes we need to export our page as an Word document or PDF file. This can be simply achieved by changing the ContentType of the Response object.

use below code to export the webpage as word document :

Page Load()
    Response.Buffer = true;
    //"application/pdf" for PDF files
    Response.ContentType = "application/msword";
    System.IO.StringWriter stringWriter = new System.IO.StringWriter();
    HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);

Thank You.

No responses found for this thread. Be the first to respond this thread.
Post Reply
Login to post Response.