/// <summary> /// Save the report to the output selected. /// </summary> /// <param name='report'> /// Report. /// </param> /// <param name='FileName'> /// File name. /// </param> private void ExportReport(Report report, string FileName, OutputPresentationType exportType) { OneFileStreamGen sg = null; try { sg = new OneFileStreamGen(FileName, true); report.RunRender(sg, exportType); } catch (Exception ex) { Gtk.MessageDialog m = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Ok, false, ex.Message); m.Run(); m.Destroy(); } finally { if (sg != null) { sg.CloseMainStream(); } } return; }
/// <summary> /// Export the report to file /// </summary> /// <param name="source">Xml source of report</param> /// <param name="parameters">Example: parameter1=someValue¶meter2=anotherValue</param> public static void Export(string source, string parameters, string fileName, OutputPresentationType exportType) { // Compile the report report = GetReport(source); if (report == null) { throw new ArgumentException("Can not compile report"); } report.RunGetData(GetParmeters(parameters)); OneFileStreamGen sg = null; try { sg = new OneFileStreamGen(fileName, true); report.RunRender(sg, exportType); } catch (Exception ex) { throw ex; } finally { if (sg != null) { sg.CloseMainStream(); } } }
private string BuildReport(string templateName, List <Param> paramList, OutputPresentationType output) { var outputFileName = GetOutputFileName(templateName, output); GeneralUtils.ChangeCurrentCultrue("es-ES"); var report = GetReport(templateName, paramList); var paramsList = GetReportParams(paramList, ref report); report.RunGetData(paramsList); var pages = report.BuildPages(); var sg = new OneFileStreamGen(outputFileName, true); switch (output) { case OutputPresentationType.Word: report.RunRender(sg, OutputPresentationType.HTML, pages); outputFileName = GetWordDocumentFromHtml(outputFileName); break; case OutputPresentationType.RenderPdf_iTextSharp: case OutputPresentationType.PDF: report.ItextPDF = true; report.RunRenderPdf(sg, pages); break; case OutputPresentationType.PDFOldStyle: report.ItextPDF = false; report.RunRenderPdf(sg, pages); break; default: report.RunRender(sg, output, pages); break; } sg.CloseMainStream(); sg.Dispose(); return(outputFileName); }
/// <summary> /// Save the file. The extension determines the type of file to save. /// </summary> /// <param name="FileName">Name of the file to be saved to.</param> /// <param name="ext">Type of file to save. Should be "pdf", "xml", "html", "mhtml".</param> public void SaveAs(string FileName, string type) { LoadPageIfNeeded(); string ext = type.ToLower(); OneFileStreamGen sg = new OneFileStreamGen(FileName, true); // overwrite with this name try { switch (ext) { case "pdf": _Report.RunRenderPdf(sg, _pgs); break; case "xml": _Report.RunRender(sg, OutputPresentationType.XML); break; case "html": case "htm": _Report.RunRender(sg, OutputPresentationType.HTML); break; case "mhtml": case "mht": _Report.RunRender(sg, OutputPresentationType.MHTML); break; default: throw new Exception("Unsupported file extension for SaveAs"); } } finally { if (sg != null) { sg.CloseMainStream(); } } return; }
/// <summary> /// Save the file. The extension determines the type of file to save. /// </summary> /// <param name="FileName">Name of the file to be saved to.</param> /// <param name="ext">Type of file to save. Should be "pdf", "xml", "html", mht.</param> private void SaveAs(Report report, string FileName, string type) { string ext = type.ToLower(); OneFileStreamGen sg = null; try { if (ext == "tifb") { FileName = FileName.Substring(0, FileName.Length - 1); // get rid of the 'b' } sg = new OneFileStreamGen(FileName, true); // overwrite with this name switch (ext) { case "pdf": if (this._StampInfo == null) { report.RunRender(sg, OutputPresentationType.PDF); } else { SaveAsPdf(report, sg); } break; case "xml": report.RunRender(sg, OutputPresentationType.XML); break; case "mht": report.RunRender(sg, OutputPresentationType.MHTML); break; case "html": case "htm": report.RunRender(sg, OutputPresentationType.HTML); break; case "csv": report.RunRender(sg, OutputPresentationType.CSV); break; case "xlsx": report.RunRender(sg, OutputPresentationType.Excel); break; case "rtf": report.RunRender(sg, OutputPresentationType.RTF); break; case "tif": case "tiff": report.RunRender(sg, OutputPresentationType.TIF); break; case "tifb": report.RunRender(sg, OutputPresentationType.TIFBW); break; default: Console.WriteLine("Unsupported file extension '{0}'. Must be 'pdf', 'xml', 'mht', 'csv', 'xslx', 'rtf', 'tif', 'tifb' or 'html'", type); returnCode = 8; break; } } catch (Exception e) { Console.WriteLine(e.Message); returnCode = 8; } finally { if (sg != null) { sg.CloseMainStream(); } } if (report.ErrorMaxSeverity > 0) { // have errors fill out the msgs Console.WriteLine("{0} has the following runtime errors:", FileName); foreach (string emsg in report.ErrorItems) { Console.WriteLine(emsg); // output message to console } report.ErrorReset(); } return; }
/// <summary> /// Save the file. The extension determines the type of file to save. /// </summary> /// <param name="FileName">Name of the file to be saved to.</param> /// <param name="ext">Type of file to save. Should be "pdf", "xml", "html", mht.</param> private void SaveAs(Report report, string FileName, string type) { string ext = type.ToLower(); OneFileStreamGen sg = null; try { bool isOldPdf = false; if (System.Environment.OSVersion.Platform == PlatformID.Unix && type == "pdf") { if (System.IO.Directory.Exists("/usr/share/fonts/truetype/msttcorefonts") == false) { isOldPdf = true; } } if (ext == "tifb") { FileName = FileName.Substring(0, FileName.Length - 1); // get rid of the 'b' } sg = new OneFileStreamGen(FileName, true); // overwrite with this name switch (ext) { case "pdf": if (this._StampInfo == null) { if (isOldPdf) { report.RunRender(sg, OutputPresentationType.PDFOldStyle); } else { report.RunRender(sg, OutputPresentationType.PDF); } } else { SaveAsPdf(report, sg); } break; case "xml": report.RunRender(sg, OutputPresentationType.XML); break; case "mht": report.RunRender(sg, OutputPresentationType.MHTML); break; case "html": case "htm": report.RunRender(sg, OutputPresentationType.HTML); break; case "csv": report.RunRender(sg, OutputPresentationType.CSV); break; case "xlsx_table": report.RunRender(sg, OutputPresentationType.ExcelTableOnly); break; case "xlsx": report.RunRender(sg, OutputPresentationType.Excel2007); break; case "rtf": report.RunRender(sg, OutputPresentationType.RTF); break; case "tif": case "tiff": report.RunRender(sg, OutputPresentationType.TIF); break; case "tifb": report.RunRender(sg, OutputPresentationType.TIFBW); break; default: Console.WriteLine("Unsupported file extension '{0}'. Must be 'pdf', 'xml', 'mht', 'csv', 'xslx', 'xlsx_table', 'rtf', 'tif', 'tifb' or 'html'", type); returnCode = 8; break; } } catch (Exception e) { Console.WriteLine(e.Message); returnCode = 8; } finally { if (sg != null) { sg.CloseMainStream(); } } if (report.ErrorMaxSeverity > 0) { // have errors fill out the msgs Console.WriteLine("{0} has the following runtime errors:", FileName); foreach (string emsg in report.ErrorItems) { Console.WriteLine(emsg); // output message to console } report.ErrorReset(); } return; }