Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i export Data grid without checkboxs and pagination links in excel.

thanks in advance
abhsihek
Posted

 
Share this answer
 
 
Share this answer
 
protected void Export_to_Excel(object sender, EventArgs e)
   {
       Response.Clear();
       Response.AddHeader("content-disposition", "attachment;filename=PatientSearchReport.xls");
       Response.ContentType = "application/vnd.xlsx";
       System.IO.StringWriter stringWrite = new System.IO.StringWriter();
       System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
       GridView1.RenderControl(htmlWrite);
       string html2 = Regex.Replace(stringWrite.ToString(), @"(<input type=""image""\/?[^>]+>)", @"", RegexOptions.IgnoreCase);
       html2 = Regex.Replace(html2, @"(<input type=""checkbox""\/?[^>]+>)", @"", RegexOptions.IgnoreCase);
       html2 = Regex.Replace(html2, @"(]+>)", @"", RegexOptions.IgnoreCase);
       Response.Write(html2.ToString());
       Response.End();
   }
 
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