Problem in Exporting ASP page in word

Discussion in 'ASP .Net Web Controls' started by Pankaj.3107@gmail.com, Jul 19, 2006.

  1. Guest

    Hello Friends

    When i export ASP page to ms word, the grid view table in word become
    to large....
    For a gridview table of 2 rows it take the whole page of ms-word....I
    am finding very difficulty
    in solving this problem...Please help me regarding this....
    Here is my Code........

    private void ExportToExcel(string filename)
    {
    Page.Response.Clear();
    Page.Response.AddHeader("content-disposition", "attachment;
    filename=" + filename);
    Page.Response.ContentType = "application/vnd.ms-word";
    Page.Response.Charset = String.Empty;
    StringWriter textWriter = new StringWriter();
    HtmlTextWriter htmlWriter = new HtmlTextWriter(textWriter);
    GridView printGV = new GridView();
    printGV.HeaderStyle.HorizontalAlign =
    System.Web.UI.WebControls.HorizontalAlign.Center;
    printGV.HeaderStyle.VerticalAlign =
    System.Web.UI.WebControls.VerticalAlign.Middle;
    printGV.HeaderStyle.BackColor = System.Drawing.Color.LightBlue;
    printGV.RowStyle.HorizontalAlign =
    System.Web.UI.WebControls.HorizontalAlign.Left;
    printGV.RowStyle.VerticalAlign =
    System.Web.UI.WebControls.VerticalAlign.Middle;
    printGV.AlternatingRowStyle.BackColor =
    System.Drawing.Color.FromArgb(239, 243, 251);
    printGV.DataSource = gridView.DataSource;
    printGV.RowDataBound += new
    GridViewRowEventHandler(printGV_RowDataBound);
    printGV.DataBind();
    printGV.RenderControl(htmlWriter);
    Page.Response.Write(textWriter.ToString());
    Page.Response.End();
    }

    }

    void printGV_RowDataBound(object sender, GridViewRowEventArgs
    e)
    {
    if (e.Row.RowType != DataControlRowType.Pager)
    {
    foreach (int i in columnsToHide)
    e.Row.Cells.Visible = false;
    }
    }
    waiting for your reply
    Thanks
    Pankaj
     
    , Jul 19, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. peteyjr
    Replies:
    1
    Views:
    652
    MWells
    Jan 19, 2005
  2. bienwell
    Replies:
    3
    Views:
    2,659
    bienwell
    May 17, 2005
  3. Franck
    Replies:
    0
    Views:
    386
    Franck
    Oct 13, 2005
  4. Franck
    Replies:
    1
    Views:
    515
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    Oct 14, 2005
  5. peteyjr
    Replies:
    1
    Views:
    254
    Bullschmidt
    Jan 18, 2005
Loading...

Share This Page