public Task <String> ExportDocumentAsync(Stream input, IDataModel dataModel, Stream output) { var r = StiReportExtensions.CreateReport(input, String.Empty); r.AddDataModel(dataModel); r.Render(); r.ExportDocument(StiExportFormat.Pdf, output, StiReportExtensions.GetDefaultPdfSettings()); return(Task.FromResult(r.ReportName)); }
public Task <ExportReportResult> ExportStiReportStreamAsync(Stream input, IStumulsoftReportInfo ri, String targetFormat, Stream output) { var r = StiReportExtensions.CreateReport(input, ri.Name); r.AddDataModel(ri.DataModel); var rr = new ExportReportResult(); if (ri.Variables != null) { r.AddVariables(ri.Variables); } if (targetFormat == "pdf") { r.Render(); r.ExportDocument(StiExportFormat.Pdf, output, StiReportExtensions.GetDefaultPdfSettings()); rr.ContentType = "application/pdf"; rr.Extension = "pdf"; } else if (targetFormat == "excel") { r.Render(); r.ExportDocument(StiExportFormat.Excel2007, output, StiReportExtensions.GetDefaultXlSettings()); rr.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; rr.Extension = "xlsx"; } else if (targetFormat == "word") { r.Render(); r.ExportDocument(StiExportFormat.Word2007, output, StiReportExtensions.GetDefaultWordSettings()); rr.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; rr.Extension = "docx"; } else if (targetFormat == "opentext") { r.Render(); r.ExportDocument(StiExportFormat.Odt, output, StiReportExtensions.GetDefaultOdtSettings()); rr.ContentType = "application/vnd.oasis.opendocument.text"; rr.Extension = "odt"; } else if (targetFormat == "opensheet") { r.Render(); r.ExportDocument(StiExportFormat.Ods, output, StiReportExtensions.GetDefaultOdsSettings()); rr.ContentType = "application/vnd.oasis.opendocument.spreadsheet"; rr.Extension = "ods"; } else { throw new NotImplementedException($"Format '{targetFormat}' is not supported in this version"); } return(Task.FromResult(rr)); }