Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Helo friends.
In my website i m exporting gridview data excel.but the problem is gridview page footer also get exported in excel...i dont want to export that in excel..how to do it??
thx in advance..
Posted
Comments
[no name] 24-Jan-13 2:16am    
better use epplus opensource for export to excel
[no name] 24-Jan-13 2:17am    
or observe the viewsource of ur page,find the footer div/tr and try to remove the tr/div in javascript before exporting to excel
Balamurugan1989 24-Jan-13 2:18am    
Right click the properties and change the Footer Setting.It will work.
Please post your codes.

private void ExportGridView()
        {
            //gvFiles.ShowFooter = false;
            System.IO.StringWriter sw = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);

            gvFiles.FooterRow.Visible = false;

            // Render grid view control.
            gvFiles.RenderControl(htw);

            // Write the rendered content to a file.
            string renderedGridView = sw.ToString();
            File.WriteAllText(@"D:\Suresh\ExportedFile.xls", renderedGridView);

           // gvFiles.ShowFooter = true;
            gvFiles.FooterRow.Visible = true;
        }
 
Share this answer
 
Make it hide while exporting
gvFiles.FooterRow.Visible = false;
 
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