I implemented export to excel functionality in asp.net application.Here i export data from Grid-view to excel-sheet.I also applied Paging in Grid-view.
So when i export data from Grid-view to excel sheet,paging text also display in excel sheet as shown in the given image.
How can we remove it
i follow the below approach for exporting data
Code-Behind:
Response.Clear()
Response.ClearHeaders()
Response.AddHeader("content-disposition", "attachment;filename=sample.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim sb As StringBuilder = New StringBuilder()
Dim objStringWriter As StringWriter = New StringWriter(sb)
Dim objHtmlTextWriter As HtmlTextWriter = New HtmlTextWriter(objStringWriter)
//gvSample is Gridview server control
gvSample.RenderControl(objHtmlTextWriter)
Response.ContentEncoding = Encoding.Unicode
Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble())
Response.Write(objStringWriter)
Response.End()
Thanks
Before rendering - disable the paging, bind the data and then render:
gvSample.AllowPaging = false;
gvSample.DataSource = ds; //Data Source
gvSample.DataBind();
gvSample.RenderControl(objHtmlTextWriter)