using System.Web; using System.Web.Security; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data; using FastReport; namespace BLL.Common { public static class FastReportService { /// /// 重置数据 /// public static void ResetData() { HttpContext.Current.Session["ReportDataTables"] = null; HttpContext.Current.Session["ReportParameterValues"] = null; } public static void AddFastreportTable(DataTable dataTable) { List dataTables = (List)HttpContext.Current.Session["ReportDataTables"]; if (dataTables == null) { dataTables = new List(); } dataTables.Add(dataTable); HttpContext.Current.Session["ReportDataTables"] = dataTables; } public static void AddFastreportParameter(Dictionary Dicparames) { HttpContext.Current.Session["ReportParameterValues"] = Dicparames; } /// /// 合并报表后打印 /// /// 报表实体集 /// 导出的路径 public static void ExportMergeReport(List fastReportItems,string path) { Report report = new Report(); report.PrintSettings.ShowDialog = false; //隐藏弹窗 FastReport.EnvironmentSettings settings = new EnvironmentSettings(); settings.ReportSettings.ShowProgress = false; //隐藏进度条 for (int i = 0; i < fastReportItems.Count; i++) { report.Load(Funs.RootPath + fastReportItems[i].ReportPath); //加载报表 List dataTables = fastReportItems[i].DataTables; Dictionary ParameterValues = fastReportItems[i].ParameterValues; if (dataTables != null && dataTables.Count > 0) { for (int j = 0; j < dataTables.Count; j++) { report.RegisterData(dataTables[j], dataTables[j].TableName);//绑定数据源 } } if (ParameterValues.Count > 0) { foreach (KeyValuePair kvp in ParameterValues) { report.SetParameterValue(kvp.Key, kvp.Value);//绑定参数 } } if (i==0) { report.Prepare(); } else { report.Prepare(true); } } FastReport.Export.Pdf.PDFExport exp = new FastReport.Export.Pdf.PDFExport(); report.Export(exp, path); } } }