Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Developers,


While Export To Excel How To dispaly full screen excel sheet in asp.net .

Thanks For Advance

Aravind G
Posted
Comments
Prasad_Kulkarni 18-Jan-12 2:57am    
have u tried any code,so we can help you exactly
Aravind Garre 18-Jan-12 3:16am    
Hi Pashad,
Thanks For Reply,
this code i am following

Response.ClearContent();

Response.AddHeader("content-disposition", "attachment; filename=GridViewToExcel.xls");

Response.ContentType = "application/excel";

StringWriter sWriter = new StringWriter();

HtmlTextWriter hTextWriter = new HtmlTextWriter(sWriter);

GridView1.RenderControl(hTextWriter);

Response.Write(sWriter.ToString());

Response.End();

1 solution

In your page directive put <code>EnableEventValidation="false"</code>

<pre lang="c#"> public void ExportGridExel()
{
string attachment = "attachment; filename=EstablishmentAllotmentDetail.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
HtmlForm frm = new HtmlForm();
if (trAllotmentDetail.Visible == true)
{
pnlGrid.Parent.Controls.Add(frm);
frm.Controls.Add(pnlGrid);
}
if (trAllotmentDetailDivision.Visible == true)
{
pnlDivision.Parent.Controls.Add(frm);
frm.Controls.Add(pnlDivision);
}
frm.Attributes["runat"] = "server";
frm.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}</pre>

<pre><pre lang="c#"></pre>public override void VerifyRenderingInServerForm(Control control)
{
/* Verifies that the control is rendered */
}
</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900