How can I generate multiple reports in a single

别等时光非礼了梦想. 提交于 2019-12-25 00:00:05

问题


I want to generate two reports in a single file that when i run my code show a file that have two page (first page was my first report and next page was my secound report) . how can i do it ?

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:


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);


来源:https://stackoverflow.com/questions/53059209/how-can-i-generate-multiple-reports-in-a-single

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!