public ActionResult ExportToExcel(int id) { Ytbl_ProgCorteModels corteResult = new Ytbl_ProgCorteModels(); var gv = new GridView(); gv.DataSource = corteResult.getReport(id); 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("Result")); }
public ActionResult Result(int id) { Ytbl_ProgCorteModels corteResult = new Ytbl_ProgCorteModels(); return(View(corteResult.getReport(id))); }