private void lbtExportToExcel_Click(object sender, EventArgs e) { string strdate = DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/" + DateTime.Now.Year.ToString(); strdate = (Convert.ToDateTime(strdate)).ToString("MMddyyyy"); string strFileName = "Organic Loyalist Summary Report " + strdate + ".xls"; StringWriter sw = new StringWriter(); string str = "field " + "smaple data"; sw.WriteLine(str); str = "Personally Enrolled Organic Loyalists: " + this.lblPEOLoyalists.Text; sw.WriteLine(str); str = "Number of Organic Loyalists in Downline: " + this.lblNOOLInDowline.Text; sw.WriteLine(str); str = "Organic Loyalists Sales: " + this.lblOLSales.Text; sw.WriteLine(str); sw.Close(); System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + strFileName); System.Web.HttpContext.Current.Response.ContentType = "application/ms-excel"; System.Web.HttpContext.Current.Response.Write(sw); System.Web.HttpContext.Current.Response.End(); }