/// <Summary>
/// Export excel in gridview
/// </Summary>
/// <Param name = "pagelocal"> Page to export </Param>
/// <Param name = "gvval"> The gridview to export </Param>
/// <Param name = "sfilename"> Exported file name </Param>
Public Static Void Excelexport (page pagelocal, gridview gvval, String Sfilename)
{
String Attachment = " Attachment; filename = " + Sfilename + " . Xls " ;
Pagelocal. response. clearcontent ();
Pagelocal. response. addheader ( " Content-Disposition " , Attachment );
Pagelocal. response. contenttype = " Application/MS-Excel " ;
Stringwriter SW = New Stringwriter ();
Htmltextwriter HTW = New Htmltextwriter (SW );
// Create a form to contain the grid
Htmlform FRM = New Htmlform ();
Gvval. Parent. Controls. Add (FRM );
FRM. attributes [ " Runat " ] = " Server " ;
FRM. Controls. Add (gvval );
FRM. rendercontrol (HTW );
// gridview1.rendercontrol (HTW );
pagelocal. response. write (SW. tostring ();
pagelocal. response. end ();
}