This is a migrated thread and some comments may be shown as answers.

Tip: Multiple Reports In One Report

7 Answers 1139 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 17 Oct 2007, 01:22 AM
I searched the Reporting forums for any example I could find about combining multiple reports together in to one report, sadly I found none what so ever. Yes there were mentions of using sub reports, but what if you had more than one report you wanted to add in there. There was no examples at all that I could find. So I sat down and started hacking away at this problem. Luckily I did find a solution that works. I hope this helps out anyone that read this, enjoy. There may be some errors here and there, as there always are in examples. But the general idea should be straight forward. Also that only the detail section of each report will be placed in the sub report at the current moment. Thank you for your time.

PageBatch.cs
public PageBatch(List<int> ItemIds) { 
            //Create new sections 
            PageHeaderSection header = new PageHeaderSection(); 
            PageFooterSection footer = new PageFooterSection(); 
            DetailSection ds = new DetailSection(); 
 
            //"Remove" the header and footer 
            header.Height = new Unit(0.1, UnitType.Pixel); 
            footer.Height = new Unit(0.1, UnitType.Pixel); 
 
            //add header 
            this.Report.Items.Add((ReportItemBase)header); 
 
            double previousLocation = 0; //this will store the offset of the Y direction 
 
            UnitType pageMeasurementType = this.PageSettings.PaperSize.Width.Type; 
 
            for(int i = 0; i < ItemIds.Count; i++){ 
                 
                //since subReport inherits from baseitem it can be fed in programmaticly 
                SubReport sb = new SubReport(); 
                sb.ReportSource = new TestPage(ItemIds[i]); 
 
                //move subreport 1.25 inches in Y direction 
                sb.Location = new PointU(new Unit(0, pageMeasurementType), new Unit(previousLocation, pageMeasurementType)); 
                sb.Width = this.PageSettings.PaperSize.Width - (this.PageSettings.Margins.Right + this.PageSettings.Margins.Left ); 
                previousLocation += this.PageSettings.PaperSize.Height.Value; 
                ds.Items.Add(sb); 
            } 
 
            this.Report.Items.Add((ReportItemBase)ds); 
            this.Report.Items.Add((ReportItemBase)footer); 
 
            this.Report.PageSettings.Margins.Top = new Unit(0.15, UnitType.Inch); 
            this.Report.PageSettings.Margins.Bottom = new Unit(0.25, UnitType.Inch); 
            this.Report.PageSettings.Margins.Left = new Unit(0.25, UnitType.Inch); 
            this.Report.PageSettings.Margins.Right = new Unit(0.25, UnitType.Inch); 
        } 

TestPage.cs
        public TestPage(int _ItemId) { 
                //do some logic here 
        } 


7 Answers, 1 is accepted

Sort by
0
Hrisi
Telerik team
answered on 17 Oct 2007, 01:14 PM
Hello John,

"Combining" multiple reports is a common request but this is an misunderstanding of the report structure and purpose.

The report is a structured view of the flat table data. This limit us to only one DataSource per report. 
In order to combine multiple views of the same data or  multiple views of related or completely different set of data we can use subreport binded to separate set of data.

This lead us to the next design problem - how to layout the subreports on the main report.

Our suggestion is to use design-time support of the Telerik Reporting. We shell use non well known possibility to add report groups without group expressions (unbound groups). Every group header/footer section can be used as a place for the separate subreport. If we set the section property PageBreak to any value different from None we can accomplish the similar result as proposed in the previous post but without any hand written code.

I hope this information helps. Thank you.

All the best,
Hrisi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
rh
Top achievements
Rank 1
answered on 16 Feb 2008, 03:25 PM
I'm planning on trying to use the group sections as essentially multiple detail sections as you described by making use of the pagebreak property. Can you guys add an item to the programming queue to be able to add multiple detail sections without the need to add groups?

I have a scenario where I have a single report where the first two pages are printed on a postcard, the third page is used for labels, and the last page is a cover letter. The operator wants it all on one report so she only has to open one PDF and then can use the print dialog to determine which pages she wants to print. This is a perfect scenario for needing multiple detail sections without needing to add groups and using the group header/footer as logical detail sections.
0
Svetoslav
Telerik team
answered on 18 Feb 2008, 10:12 AM
Hi Roy,

We have already thought of allowing more than one report section (not page section!) of a type to coexist in one report. However, currently I cannot provide you with information about the version in which we will implement it. As soon as we have an idea when we can work on this it will become part of the product roadmap.

Regards,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
David
Top achievements
Rank 1
answered on 18 Feb 2008, 11:26 AM
Hi Svetoslav

I don't know if it is possible in the current version but, reading this post I remember an utility tha I had on activereports that was helpful about this.

Thinking a report equal to collection of pages, if we can run several reports on background for example in a for statement and after each one we can clone the pages of the report into a new report page collection, it will should solve this issue.

it should be something like this:

dim rpt as new telerik.reporting.report  
 
dim rpt1 as new report1  
rpt1.run  
 
for x as integer=0 to rpt1.pages.count-1  
 rpt.pages.add(rpt1.pages(x).clone)  
next  
 
dim rpt2 as new report2  
rpt2.run  
 
for x as integer=0 to rpt2.pages.count-1  
 rpt.pages.add(rpt2.pages(x).clone)  
next  
 
........  
 
'to make pagenumbers and pageheaders  
dim rptfinally1 as new rptfinally  
rptfinally.subreportitem.report=rpt  
 
reportviewer1.report=rptfinally  
reportviewer.refreshreport()  
 
 
     

Along with this it should be useful to run the report before we put it on a reportviewer and without the need to use the print method or the refreshreport method. This will be a way to serialize the report result before it will be exported to any format or printed or viewed.


If all of this works fine in current version ignore this message, I'm new on telerik reporting and today I had not explore all of the library.
Regards

David Tomás
0
Svetoslav
Telerik team
answered on 19 Feb 2008, 08:22 AM
Hi David,

I am afraid that Telerik Reporting does not support the described page operation. Anyway it seems quite interesting and we will definitely examine it.

Sincerely yours,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Hisham Abbas
Top achievements
Rank 1
answered on 17 Mar 2008, 02:50 PM
Hi All,
I would like to join multiple report in a single one. I've tried John's code and it's working fine if I have a single page report, but for a report that contains more than one page, the reports are overlapping. Any idea how to solve this problem?
Thanks.
Issa Salama.
0
Svetoslav
Telerik team
answered on 18 Mar 2008, 11:28 AM
Hi Issa Salama,

In order to examine the issue yo are faced with, please, open a separate support ticket and send us a sample report that illustrates the exact problem.

Best wishes,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
John
Top achievements
Rank 1
Answers by
Hrisi
Telerik team
rh
Top achievements
Rank 1
Svetoslav
Telerik team
David
Top achievements
Rank 1
Hisham Abbas
Top achievements
Rank 1
Share this question
or