Append prepared pages

edited February 2013 in FastReport .NET
Hello,

I'am using this code to append prepared pages from multiple (prepared) reports to new report and show all results in one report preview window (without tabs) and everything works great if report doesn't have subreports. If it does, it throws an exception.

Code:
                    FastReport.Report rep = new FastReport.Report();
                    rep.Prepare();

                    var ind = 0;
                    foreach (FastReport.Report pp in reports)
                    {
                        for (int i = 0; i < pp.PreparedPages.Count; i++)
                        {
                            var page = pp.PreparedPages.GetPage(i);

                            rep.PreparedPages.AddSourcePage(page);
                            rep.PreparedPages.AddPage(page);
                            rep.PreparedPages.ModifyPage(ind, page);

                            ind++;
                        }
                    }

Exception (when report has subreports):
wrote:
Objekt tipa ReportSummaryBand ne mo??e sadr??avati objekte tipa DataHeaderBand
(Object of type ReportSummaryBand can't contain objects of type DataHeaderBand)

Stack trace:

at FastReport.Base.SetParent(Base value)
at FastReport.Utils.FRCollectionBase.OnInsert(Int32 index, Object value)
at System.Collections.CollectionBase.System.Collections.IList.Add(Object value)
at FastReport.BandBase.AddChild(Base child)
at FastReport.Base.set_Parent(Base value)
at FastReport.Preview.SourcePages.CloneObjects(Base source, Base parent)
at FastReport.Preview.SourcePages.CloneObjects(Base source, Base parent)
at FastReport.Preview.SourcePages.CloneObjects(Base source, Base parent)
at FastReport.Preview.SourcePages.Add(ReportPage page)
at IPIS.StatusListControl.(Object , ItemClickEventArgs )
at DevExpress.XtraBars.BarItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarBaseButtonItem.OnClick(BarItemLink link)
at DevExpress.XtraBars.BarItemLink.OnLinkClick()
at DevExpress.XtraBars.BarItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.BarButtonItemLink.OnLinkAction(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.BarItemLink.OnLinkActionCore(BarLinkAction action, Object actionArgs)
at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.ClickLink(BarItemLink link)
at DevExpress.XtraBars.ViewInfo.BarSelectionInfo.UnPressLink(BarItemLink link)
at DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnUnPressItem(DXMouseEventArgs e, RibbonHitInfo hitInfo)
at DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnUnPress(DXMouseEventArgs e, RibbonHitInfo hitInfo)
at DevExpress.XtraBars.Ribbon.Handler.BaseRibbonHandler.OnMouseUp(DXMouseEventArgs e)
at DevExpress.XtraBars.Ribbon.Handler.RibbonHandler.OnMouseUp(DXMouseEventArgs e)
at DevExpress.XtraBars.Ribbon.RibbonControl.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at DevExpress.Utils.Controls.ControlBase.WndProc(Message& m)
at DevExpress.XtraBars.Ribbon.RibbonControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I got this code from expermenting with various solutions and it's most close to that what I need.

Any advice from your side?

Thanks in advance

Ivica

Comments

  • edited 11:44PM
    I was lazy, solution is in programmers manual and on this forum:
    Report report = new Report();
    report.Load("report1.frx");
    report.Prepare();
    report.Load("report2.frx");
    report.Prepare(true); // Crucial parameter Append=true
    report.ShowPrepared();
    

    Sorry for taking your time!

    Ivica

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.