Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=SalesPersonreport.xls"); Response.Charset = ""; // If you want the option to open the Excel file without saving then // comment out the line below // Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); GridView gvExport = new GridView();// grid a grid typr instance for exporting grid data to excel if (dsReport.Tables[0].Rows.Count > 0) { gvExport.DataSource = dsReport;//objbus.ExporttoExcel(querryvalue); gvExport.DataBind(); } gvExport.RenderControl(htmlWrite); // rendering grid data to html writter Response.Write(stringWrite.ToString()); //this will prompt Download message