public override void ExecuteResult(System.Web.Mvc.ControllerContext context) { context.HttpContext.Response.Clear(); context.HttpContext.Response.ContentType = getContentType(type); context.HttpContext.Response.AddHeader("Content-Disposition", "attachment;filename=" + saveName); var report = new RPT(file, type, listData, parameters); var buffer = report.readRPT(); context.HttpContext.Response.BinaryWrite(buffer); }
public static byte[] byteResult(genericReportData data) { string _file = string.Empty; string _ext = ".pdf"; try { _file = data.PathRPT.Trim().Substring(data.PathRPT.Length - 1) == @"\" ? data.PathRPT + (string.IsNullOrEmpty(data.area) ? string.Empty : data.area + @"\") + data.fileRPT : data.PathRPT.Trim() + @"\" + (string.IsNullOrEmpty(data.area) ? string.Empty : data.area + @"\") + data.fileRPT; if (System.IO.File.Exists(_file)) { //CrystalDecisions.Shared.ExportFormatType _exportType; //if (data.exportTO == RP.Saude.Report.RPT.ExportFormatType.DOC) //{ // _exportType = CrystalDecisions.Shared.ExportFormatType.WordForWindows; // _ext = ".doc"; //} //else if (data.exportTO == RP.Saude.Report.RPT.ExportFormatType.HTML) //{ // _exportType = CrystalDecisions.Shared.ExportFormatType.HTML40; // _ext = ".html"; //} //else if (data.exportTO == RP.Saude.Report.RPT.ExportFormatType.TXT) //{ // _exportType = CrystalDecisions.Shared.ExportFormatType.RichText; // _ext = ".txt"; //} //else if (data.exportTO == RP.Saude.Report.RPT.ExportFormatType.XLS) //{ // _exportType = CrystalDecisions.Shared.ExportFormatType.Excel; // _ext = ".xls"; //} //else //{ // _exportType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat; //} var rep = new RPT( _file, data.exportTO, data.listData, data.parameters); return rep.readRPT(); } return null; } finally { /* dispose method */ } }