Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Export ASPX Web page to MS Word

Posted on 2007-04-08
1
Medium Priority
?
1,797 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 500 total points
ID: 18874150
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

670 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