/// <summary> /// The report will be generated, but not shown to the user. /// </summary> /// <param name="ACalc"></param> /// <param name="Format"></param> public MemoryStream ExportToStream(TRptCalculator ACalc, ReportExportType Format) { MemoryStream HtmlStream = new MemoryStream(); object exporter; Type ExporterType; if (Format == ReportExportType.Pdf) { exporter = FastReportsDll.CreateInstance("FastReport.Export.Pdf.PDFExport"); ExporterType = exporter.GetType(); ExporterType.GetProperty("EmbeddingFonts").SetValue(exporter, false, null); } else // otherwise do HTML - text is not yet supported. { exporter = FastReportsDll.CreateInstance("FastReport.Export.Html.HTMLExport"); ExporterType = exporter.GetType(); } FFastReportType.GetMethod("LoadFromString", new Type[] { FSelectedTemplate.XmlText.GetType() }).Invoke(FfastReportInstance, new object[] { FSelectedTemplate.XmlText }); LoadReportParams(ACalc); FFastReportType.GetMethod("Prepare", new Type[0]).Invoke(FfastReportInstance, null); FFastReportType.GetMethod("Export", new Type[] { ExporterType, HtmlStream.GetType() }).Invoke(FfastReportInstance, new Object[] { exporter, HtmlStream }); return(HtmlStream); }
public static IExporter GetExporter(ExporterType type) { switch (type) { case ExporterType.Csv: return(new CsvExporter()); case ExporterType.Excel: return(new ExcelExporter()); default: throw new NotSupportedException(); } }
public static Exporter getExporter(ExporterType type) { switch (type) { case ExporterType.CsvExporter: { return(new CsvExporter()); } case ExporterType.JsonExporter: { return(new JsonExporter()); } default: return(null); } }
private void handleFinishEdit(object sender, System.Collections.Specialized.OrderedDictionary e) { if (sender.Equals(this.addTicket)) { string code = e[Constants.codeField].ToString(); string spectacol = e[Constants.spectacolField].ToString(); int nrOfTickets = SpectacleBL.getNrOfTicketsForSpectacle(spectacol); if (nrOfTickets == 0) { MessageBox.Show("Cannot add more tickets"); return; } else if (nrOfTickets == -1) { MessageBox.Show("Bad request,please check fields"); return; } int rand = int.Parse(e[Constants.randField].ToString()); int numar = int.Parse(e[Constants.numarField].ToString()); OperationResult.opResult result = TicketBL.addTicketForSpectacle(code, spectacol, rand, numar); if (result == OperationResult.opResult.OperationInsertTicketDuplicate || result == OperationResult.opResult.OperationAddTicketFail) { MessageBox.Show("Cannot add ticket for this place"); return; } else { MessageBox.Show("Succes"); } } else if (sender.Equals(this.export)) { ExporterType type = (ExporterType)int.Parse(e["Export Type"].ToString()); Exporter exporter = ExportFactory.getExporter(type); string spectacol = e[Constants.spectacolField].ToString(); Array tickets = TicketBL.getAllTicketsForSpectacle(spectacol).ToArray(); string path = e["File Path"].ToString(); exporter.exportTickets(tickets.OfType <Ticket>().ToList(), path); } }