Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Problem in Exporting ASP page in word

Reply
Thread Tools

Problem in Exporting ASP page in word

 
 
Pankaj.3107@gmail.com
Guest
Posts: n/a
 
      07-19-2006
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[i].Visible = false;
}
}
waiting for your reply
Thanks
Pankaj

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting Web page to word in Asp.net(c#) amey.rane86 Software 0 10-06-2009 01:49 PM
exporting word file content to aspx web page Franck ASP .Net 1 10-14-2005 01:07 PM
exporting word file content to aspx web page Franck ASP .Net 0 10-13-2005 01:58 PM
Exporting data into Excel, Word in ASP.NET - Please help !!! bienwell ASP .Net 3 05-17-2005 07:49 PM
Exporting data into a MS Word Serial Letter via ASP.NET peteyjr ASP .Net 1 01-19-2005 08:03 PM



Advertisments