Solved

Export ASPX Web page to MS Word

Posted on 2007-04-08
1
1,796 Views
Last Modified: 2012-06-21
I have an .NET 2.0 aspx web page that contains a combination of HTML Table with Lables and Literals embedded throughout the tables and I also have one GridView object on the page.   I want to know how to export that entire page to an MS-WORD document.

I have the page display in the Web form with a link button that says "Export to Word",  when they click on that link they are redirected to Web page formatted for the print output, which is basically the same page without the banners, menus, etc.

On the page I have the following fuction to export to Word.  I was try to use the same method I did for export a GridView object on a page to excel, which is a slightly different need that i have here.  Instead if rendering out just one control, I want to render the entire page.

Here is a snippit of code I am try to work with..which doesn't work....

-------------- Start Code Sample ---------------------------------------
        protected void ExportReport()
        {
            Response.Clear();

            Response.AddHeader("content-disposition", "attachment; filename=FastAirReport.doc");

            this.EnableViewState = false;
            Response.Charset = String.Empty;

            Response.ContentType = "application/vnd.ms-word";
            //Response.ContentType = "application/vnd.xls";

            System.IO.StringWriter stringWrite = new System.IO.StringWriter();

            System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

            //GridView1.RenderControl(htmlWrite);
            form1.RenderControl(htmlWrite);
         
           
           

            Response.Write(stringWrite.ToString());

            Response.End();


        }
        public override void VerifyRenderingInServerForm(Control form1)
        {

            // Confirms that an HtmlForm control is rendered for the
            //specified ASP.NET server control at run time.

        }

---------------------- End Code Sample ---------------------------------------------

Any help would be appreciated.

Thanks
0
Comment
Question by:jholmes724
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 12

Accepted Solution

by:
sandip132 earned 125 total points
ID: 18874150
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question