string fileName = string.Empty; if (rdDailySales.Checked) fileName = rdDailySales.Text + "_" + DateTime.Now.Date.Day.ToString() + "_" + DateTime.Now.Date.Month.ToString() + "_" + DateTime.Now.Date.Year.ToString(); else fileName = rdDsr.Text + "_" + DateTime.Now.Date.Day.ToString() + "_" + DateTime.Now.Date.Month.ToString() + "_" + DateTime.Now.Date.Year.ToString(); Response.Clear(); Response.Charset = ""; Response.ContentEncoding = System.Text.UTF8Encoding.UTF8; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/ms-excel.xls"; Response.AddHeader("content-disposition", "attachment;filename=" + fileName + ".xls"); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); firstRow.RenderControl(hw); //sencondRow.RenderControl(hw); if (rdDsr.Checked) dbReport.RenderControl(hw); //divbreak.RenderControl(hw); //thirdRow.RenderControl(hw); if (rdDailySales.Checked) dbReport1.RenderControl(hw); FileInfo fi = new FileInfo(Server.MapPath("../Styles/jquery.dataTablesExcel.css")); StringBuilder sb1 = new StringBuilder(); StreamReader sr = fi.OpenText(); while (sr.Peek() >= 0) { sb1.Append(sr.ReadLine()); } sr.Close(); Response.Write("<html><head><style type='text/css'>" + sb1.ToString() + "</style><head>" + sw.ToString() + "</html>"); sw = null; hw = null; Response.Flush(); Response.End();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)