Report Merging

Stimulsoft Reports.JS discussion
BCS
Posts: 83
Joined: Thu Nov 17, 2016 5:47 am

Report Merging

Post by BCS »

Is it possible to merge or append different reports together as in different (*.mrt) files. I know one can make different pages in one report but the scope of my requirements require me to obtain external documents or agreements or other analytics reports which I can template but each end product will be different and may or may not use all pages.

My guess was probably to gain access to the page collection before rendering but I'm at a lose how to proceed from there if its even possible.

I am using Stimulsoft Reports.JS
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Report Merging

Post by Lech Kulikowski »

Hello,

You can use the following code:

Code: Select all

var report1 = new Stimulsoft.Report.StiReport();
report1.loadFile("Reports/1.mrt");
var report2 = new Stimulsoft.Report.StiReport();
report2.loadFile("Reports/2.mrt");
var reportMerge = new Stimulsoft.Report.StiReport();
reportMerge.reportUnit = report1.reportUnit;
reportMerge.render();
reportMerge.renderedPages.clear();
report1.renderAsync(function () {
    for (var index = 0; index < report1.renderedPages.count; ++index) {
        reportMerge.renderedPages.add(report1.renderedPages.getByIndex(index));
    }
});
report2.renderAsync(function () {
    for (var index = 0; index < report2.renderedPages.count; ++index) {
        reportMerge.renderedPages.add(report2.renderedPages.getByIndex(index));
    }
});
viewer.report = reportMerge;
viewer.renderHtml("viewerCont");
Thank you.
BCS
Posts: 83
Joined: Thu Nov 17, 2016 5:47 am

Re: Report Merging

Post by BCS »

Okay thank you I will give it a try and let you know.
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Report Merging

Post by Lech Kulikowski »

Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.
BCS
Posts: 83
Joined: Thu Nov 17, 2016 5:47 am

Re: Report Merging

Post by BCS »

I do have an additional question, how does one reset the page numbering so that the page numbering is contiguous and not 1 of 4 then for the next report 1 of 7 for instance instead of 1 of 11?
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Report Merging

Post by Lech Kulikowski »

Hello,

You can try to use an additional variable for page numbering. After first report rendering set the count of pages to that variable and provide it in the second report.

Thank you.
BCS
Posts: 83
Joined: Thu Nov 17, 2016 5:47 am

Re: Report Merging

Post by BCS »

Is it possible to update the previous example with this concept, I'm still having trouble with it.
BCS
Posts: 83
Joined: Thu Nov 17, 2016 5:47 am

Re: Report Merging

Post by BCS »

I am also having an issue where sometimes it will not render the report with renderAsync, i have to refresh the page to make it work properly. Is there a way to know when the report is done rendering?
BCS
Posts: 83
Joined: Thu Nov 17, 2016 5:47 am

Re: Report Merging

Post by BCS »

BCS wrote: Wed Sep 26, 2018 5:10 am I am also having an issue where sometimes it will not render the report with renderAsync, i have to refresh the page to make it work properly. Is there a way to know when the report is done rendering?
I think I solved this issue by making each report be "reportX.isAsych = true"
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Report Merging

Post by Lech Kulikowski »

Hello

Ok.
Please let us know if you need any additional help.

Thank you.
Post Reply