public static void OutputReport(Control grid, string reportName, System.Data.DataTable dataSource, ReportDestinations outputTarget, ActionParameters reportParameters) { if (_reporter != null) { _reporter.OutputReport(reportName, dataSource, outputTarget, reportParameters); } }
public static void OutputReport(Control grid, string reportName, System.Data.DataTable dataSource, ReportDestinations outputTarget) { OutputReport(grid, reportName, dataSource, outputTarget, null); }
void IReporter.OutputReport(string reportName, DataTable dataSource, ReportDestinations outputTarget, ActionParameters reportParameters) { _outputReport(reportName, dataSource, outputTarget, null, reportParameters); }
//Для возможного использования //foreach (Stimulsoft.Report.Dictionary.StiVariable variable in report.Dictionary.Variables) //{ // variable.Value = dbs.GetSetting(variable.Name.Replace('_', ';')); //} //StiReport r = new StiReport(); //r.Render(); //r.RenderedPages.Remove(r.RenderedPages[0]); //r.RenderedPages.AddRange(report.RenderedPages); //r.RenderedPages.Add(report.RenderedPages[0]); //r.Show(true); static void _outputReport(string reportName, DataTable dataSource, ReportDestinations outputTarget, ReportExportFormat format, ActionParameters reportParameters) { string reportsPath = System.IO.Path.Combine(PathHelper.ApplicationPath, "Reports"); string reportFilePath = System.IO.Path.Combine(reportsPath, reportName.EndsWith(ReportFileExtension) ? reportName : reportName + ReportFileExtension); StiReport report = new StiReport(); bool loaded = false; if (System.IO.File.Exists(reportFilePath)) { report.Load(reportFilePath); loaded = true; } else { throw new System.IO.FileNotFoundException($"Report file {reportsPath} not fount"); } if (loaded) { string tableName = TableAliasDefault;; StiDataBand db = report.GetComponents().OfType <StiDataBand>().FirstOrDefault(); if (db != null) { if (!string.IsNullOrEmpty(db.DataSourceName)) { tableName = db.DataSourceName; } else { db.DataSourceName = tableName; } } dataSource.TableName = tableName; report.RegData(dataSource.TableName, dataSource); report.Dictionary.Synchronize(); report.Dictionary.DataSources[0].Name = tableName; report.Dictionary.DataSources[0].Alias = tableName; if (reportParameters != null) { foreach (KeyValuePair <string, object> kvp in reportParameters) { if (!report.Dictionary.Variables.Contains(kvp.Key)) { report.Dictionary.Variables.Add("Parameters", kvp.Key, kvp.Value); } else { report.Dictionary.Variables[kvp.Key].ValueObject = kvp.Value; } } } if (outputTarget == ReportDestinations.Designer) { report.Design(false); } else if (outputTarget == ReportDestinations.Printer) { report.Render(true); report.Print(true); } else if (outputTarget == ReportDestinations.File) { if (format == null) { format = ReportManager.GetExportReportFormat( reportName.EndsWith(ReportFileExtension) ? reportName.Left(reportName.Length - ReportFileExtension.Length) : reportName, ReportExportFormats.Formats.First().Value.ID); } if (format != null) { report.Render(true); if (format.CreateParam.Charset == ReportExportCharsets.Windows_1251) { report.ExportDocument(GetExportFormat(format.ID), format.CreateParam.ExportFileName, new Stimulsoft.Report.Export.StiHtmlExportSettings() { Encoding = System.Text.Encoding.Default }); } else { report.ExportDocument(GetExportFormat(format.ID), format.CreateParam.ExportFileName); } } } else { report.Render(true); report.Show(); } } }
void IReporter.OutputReport(string reportName, DataTable dataSource, ReportDestinations outputTarget) { _outputReport(reportName, dataSource, outputTarget, null, null); }