Mahesh Reddy

Mahesh Reddy

  • NA
  • 363
  • 17.1k

Need Sample Mock code For Below Shared code in C#

Nov 25 2021 7:19 AM
public ActionResult ExportToExcel() {  
    var gv = new GridView();  
    gv.DataSource = this.GetEmployeeList();  
    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("Index");  
}

can please anyone help me 


Answers (3)