public ActionResult DescargarReporteAsignaciones(int?id) { try { //var asignaciones = ProyectoCN.ListarAsignaciones(); var rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Reportes/AsignacionReport.rpt"); rptH.Load(); if (id == null) { rptH.SetDataSource(ProyectoCN.ListarAsignaciones()); } else { rptH.SetDataSource(ProyectoCN.ListarAsignaciones(id.Value)); } Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); //En PDF Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); rptH.Dispose(); rptH.Close(); return(new FileStreamResult(stream, "application/pdf")); } catch (Exception ex) { throw; } }
public ActionResult DescargarReporteAsignacionesExcel(int?id) { try { var rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Reportes/AsignacionReport.rpt"); rptH.Load(); if (id == null) { rptH.SetDataSource(ProyectoCN.ListarAsignaciones()); } else { rptH.SetDataSource(ProyectoCN.ListarAsignaciones(id.Value)); } // Report connection var connInfo = CrystalReportsCnn.GetConnectionInfo(); TableLogOnInfo logonInfo = new TableLogOnInfo(); Tables tables; tables = rptH.Database.Tables; foreach (Table table in tables) { logonInfo = table.LogOnInfo; logonInfo.ConnectionInfo = connInfo; table.ApplyLogOnInfo(logonInfo); } Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); // Descargar en Excel Stream stream = rptH.ExportToStream(ExportFormatType.Excel); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/vnd.ms-excel", "asignacionRpt.xls")); } catch (Exception ex) { return(Json(new { ok = false, msg = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AsignarProyecto() { return(View(ProyectoCN.ListarAsignaciones())); }