Dear Friends
i am trying to export list data to excel but neither i am getting any error nor my my task is getting accomplished, no excel file is being downloaded.
someone please help.
someone please help.
code is given below
public ActionResult lnkExportData()
{
EmployeeHome EmpHome = new EmployeeHome();
List objEmployeeList = new List();
EmpHome.BindEmployee(1, "", "", "", "");
var list = EmpHome.ListLanguageEmployee;
var Records = list.Select(x => new { UserName = x.UserName, Name = x.ImageFilePath + ' ' + x.LastName + '-' + '(' + x.EmpCode + ')', Designation = x.Designation, CellularNumber = x.CellPhone, EmailID = x.EmailId, JoiningDate = String.Format("{0:dd-MMM-yyyy}", x.JoiningDate), Status = x.Status == 1 ? "Active" : "Inactive" }).ToList();
var gv = new GridView();
gv.DataSource = Records;
gv.DataBind();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename=DemoExcel.xls");
Response.ContentType = "application/ms-excel";
Response.Charset = "";
StringWriter objStringWriter = new StringWriter();
HtmlTextWriter objHtmlTextWriter = new HtmlTextWriter(objStringWriter);
gv.RenderControl(objHtmlTextWriter);
Response.Output.Write(objStringWriter.ToString());
Response.Flush();
Response.End();
return View();
}

Akshay PhadkePosted Aug 29, 2017, 3:49 AM
issacpalPosted Aug 29, 2017, 3:22 AM
Nilesh ShahPosted Aug 22, 2017, 8:05 AM
Ankit KumarPosted Aug 22, 2017, 12:56 AM
Nilesh ShahPosted Aug 21, 2017, 9:02 AM
Manas MohapatraPosted Aug 21, 2017, 7:55 AM
Ankit KumarPosted Aug 21, 2017, 6:57 AM
Manas MohapatraPosted Aug 21, 2017, 6:53 AM