如何在一个报告中生成多个报告

时间:2018-10-30 07:20:16

标签: c# asp.net-mvc stimulsoft

我想在一个文件中生成两个报告,该文件在运行代码时显示一个具有两页的文件(第一页是我的第一个报告,下一页是我的安全报告)。 我该怎么办?

public ActionResult GetReport(Guid? productionId){
StiReport report = new StiReport();
report.Load(Server.MapPath("~/Reports/ElementProduction.mrt"));
report.Load(Server.MapPath("~/Reports/ElementProduction2.mrt"));
return StiMvcViewer.GetReportResult(report);
}

1 个答案:

答案 0 :(得分:0)

public ActionResult GetReport(Guid? productionId){
report.Load(Server.MapPath("~/Reports/ElementProduction1.mrt"));
StiReport report = new StiReport();
report.Compile();
report.Render();
StiReport report2 = new StiReport();
report.Load(Server.MapPath("~/Reports/ElementProduction2.mrt"));
report2.Compile();
report2.Render();

StiReport joinedReport = new StiReport();
joinedReport.NeedsCompiling = false;
joinedReport.IsRendered = true;
joinedReport.RenderedPages.Clear();

foreach (StiPage page in report1.CompiledReport.RenderedPages)
{
    page.Report = joinedReport;
    page.NewGuid();
    joinedReport.RenderedPages.Add(page);
}
foreach (StiPage page in report2.CompiledReport.RenderedPages)
{
    page.Report = joinedReport;
    page.NewGuid();
    joinedReport.RenderedPages.Add(page);
}

return StiMvcViewer.GetReportResult(joinedReport);