C1FlexReport Concatenate or Merge Multiple Reports

Posted by: jnash on 26 April 2021, 1:33 am EST

    • Post Options:
    • Link

    Posted 26 April 2021, 1:33 am EST

    Hello,

    Is there currently a recommended way to merge or concatenate two or more C1FlexReports. Reports will use the same page size and orientation (letter, portrait). I would like to load and generate distinct reports as needed but ultimately merge the results into a single final report. This would ultimately be exported/filtered out to a PDF and written to disk or converted to a memory stream and sent as a response to a web client.

    I was unable to find a Forum discussion of something like this so any links or suggestions would be greatly appreciated.

    Thanks

  • Posted 26 April 2021, 3:44 pm EST

    Hi,

    In order to achieve this, you can obtain the images for each report’s pages using the GetPageImage method:

    https://www.grapecity.com/componentone/docs/win/online-flexreport/C1.Win.FlexReport.4.5.2~C1.Win.FlexReport.C1FlexReport~GetPageImage.html

    Then you will need to add these images to a new report using the ImageField.

    Please refer to the sample attached.

    You can also refer to the forum post: https://www.grapecity.com/forums/winforms-edition/merging-multiple-flexrepor

    Regards.

    Avnish

    MergeFlexReport.zip

  • Posted 26 April 2021, 10:18 pm EST

    Thank you. This seems more complex and resource intensive than I had hoped but at least there is a way to proceed.

    Would ActiveReport provide this functionality in a more straightforward way or would it also require a similar approach?

    Thanks

  • Posted 27 April 2021, 3:55 pm EST

    Hello,

    It is directly possible with ActiveReports. You can refer to the following link:

    For Page/Rdl Report:

    https://www.grapecity.com/activereportsnet/docs/v15/online/merge-multiple-reports.html

    For Section Report:

    https://www.grapecity.com/activereportsnet/docs/v15/online/insert-or-add-pages.html

    To know more about the difference of Page, RDL and Section report, you can refer to the following link:

    https://www.grapecity.com/activereportsnet/docs/v15/online/reporttypes.html

    Please feel free to revert if you face any issue, I would be more than happy to help you.

    Thanks,

    Mohit

  • Posted 17 August 2022, 10:32 pm EST

    Hello @GrapeCity Team,

    I’m trying to merge C1FlexReports through C# , but i’m not able to figure out a way on achieving this no matter what blog i follow .

    Requirement ,

    C1FlexReport report_1 = new C1FlexReport();
    C1FlexReport report_2 = new C1FlexReport();
    

    now I want to merge report_2 with report_1 .

    Please help through code.

    Thanks!

  • Posted 18 August 2022, 9:57 pm EST

    Hi,

    There’s no direct way to merge two reports into one. You need to follow the same approach which is already responded in this thread.

    You need to generate images for all pages of both reports. And then need to add all generated images into another report using ImageField. (see code snippet)

    
           private C1FlexReport MergeReports(C1FlexReport report_1, C1FlexReport report_2)
            {
                var mergeFlex = new C1FlexReport();
                mergeFlex.Sections.PageFooter.Height = 0;
                mergeFlex.Sections.PageHeader.Height = 0;
                mergeFlex.Sections.Header.Height = 0;
                mergeFlex.Sections.Footer.Height = 0;
    
                mergeFlex.Layout.MarginBottom = 0;
                mergeFlex.Layout.MarginLeft = 0;
                mergeFlex.Layout.MarginRight = 0;
                mergeFlex.Layout.MarginTop = 0;
                mergeFlex.Sections.Detail.AutoHeight = AutoSizeBehavior.GrowAndShrink;
                mergeFlex.Sections.Detail.Visible = true;
    
                for (int i = 0; i < report_1.PageCount; i++)
                {
                    img = new ImageField();
                    SubSection section = mergeFlex.Sections.Detail.SubSections.Add();
                    section.Visible = true;
                    section.Height = mergeFlex.Layout.PageSize.Height;
                    section.AutoHeight = AutoSizeBehavior.None;
                    img.Picture = report_1.GetPageImage(i);
                    img.Left = 0;
                    img.Top = 0;
                    img.AutoWidth = AutoSizeBehavior.CanGrow;
                    img.AutoHeight = AutoSizeBehavior.GrowAndShrink;
                    section.Fields.Add(img);
                }
    
                for (int i = 0; i < report_2.PageCount; i++)
                {
                    img = new ImageField();
                    SubSection section = mergeFlex.Sections.Detail.SubSections.Add();
                    section.Visible = true;
                    section.Height = mergeFlex.Layout.PageSize.Height;
                    section.AutoHeight = AutoSizeBehavior.None;
                    img.Picture = report_2.GetPageImage(i);
                    img.Left = 0;
                    img.Top = 0;
                    img.AutoWidth = AutoSizeBehavior.CanGrow;
                    img.AutoHeight = AutoSizeBehavior.GrowAndShrink;
                    section.Fields.Add(img);
                }
                return mergeFlex;
            }
    
    

    Please refer the attached sample for the same: MergeFlexReport.zip

    Best Regards,

    Nitin

  • Posted 21 August 2022, 10:28 pm EST

    Hello Nithin,

    Thanks for the snippet and it works very well for reports present in different flxr files .

    I needed another snippet where in there are multiple subreports for a single report in the same flxr files.

    The data source for all the subreports are different.

    Now , i’m able to get the list of all reports in the flxr file and able to pump in data to them.

    Later when i’m trying to export it, all the subreports are getting generated as a different page in the pdf.

    What i’m looking for is a combined report .

    Below is the code that i tried .

    List<C1FlexReport> listreports = _reportList.Select(x => x.Report).ToList();
    The list contains the main report as well as the subreports 
    
     foreach (var item in listreports)
                    {
                      
                        DataSource dss = new DataSource();
                        dss.DataProvider = DataProvider.ExternalObject;
    
                        DataSet dset = new DataSet();
                        dset.ReadXml(xmlpath);
                        item.DataSource.Recordset = dset.Tables[//respective datasource];
                        item.Render();
                    }
    
    //doing foreach on all the items in the list and trying to merge them into the main reports image ; 
    
    C1FlexReport mergeFlex = flexReportList.first(); //getting the first main report from list;
    
     foreach (var _reportItem in flexReportList)
                {
                    for (int i = 0; i < _reportItem.PageCount; i++)
                    {
                        ImageField img = new ImageField();
                        SubSection section = mergeFlex.Sections.Detail.SubSections.Add();
                        section.Visible = true;
                        section.Height = mergeFlex.Layout.PageSize.Height;
                        section.AutoHeight = AutoSizeBehavior.None;
                        img.Picture = _reportItem.GetPageImage(i);
                        img.Left = 0;
                        img.Top = 0;
                        img.AutoWidth = AutoSizeBehavior.CanGrow;
                        img.AutoHeight = AutoSizeBehavior.GrowAndShrink;
                        section.Fields.Add(img);
                    }
                }
    

    However, this gives me 1 pdf but with different pages for all the subreports.

    Any idea as to how to get all of them as designed through the designer (as in a single page) .

  • Posted 22 August 2022, 9:49 pm EST

    Hi,

    Apologize for the inconvenience. We are unable to understand your requirement.

    As per our observation, you are trying to merge the Main report and Sub-Report which is linked in Main report.

    JFYI, If Subreport is linked with the Main report then it will be included in the Main report on rendering. So, you don’t need to merge Main report and Sub report. As Subreports included in Main repots already.

    If we are not clear about your requirement. Then please share a sample report with details of your requirement. So, that we can assist you accordingly.

    Best Regards,

    Nitin

  • Posted 1 September 2022, 9:31 pm EST

    Hello @GrapeCity Team,

    This is the requirement.

    I have a flxr file wherein i need to create subreports based on XML tags .

    Each subreport will be created based on XML node level.

    All the subreports will need to be imported into a master report .

    Problem statement

    When i’m designing the report , i’m not able to select the datafields for the report based on the xml attributes that are present.

    For example :

    There is a Test Node with attributes such as TestName , TestValue , ReferenceRange .

    All these needs to be present as data fields in the report RelatedTests (which is a

    sub report for TestInfo Report)

    While creating the RelatedTests report it doesn’t allow to select the attributes as fields .

    Is there a way to do this ? If yes , how .

    Finally , all the present in the xml should be available in the reports so that the master report can be generated.

    Also, this should be able to achieve through programatically as well. (Need the code for this )

    We tried using SQL as data source and its easily possible, but we are not able to achieve it through xml data source.

    I have attached the flxr file , the xml data source the output that we are getting .

    Please have a look and guide us through .

    Thanks,

    Bharath

    sample-data.zip

  • Posted 4 September 2022, 10:52 pm EST

    Hi Bharath,

    Thanks for the sample report.

    As we observed, you are referencing nested data items as field from a given DataSource which can’t be possible to fetch item from xml node and render it into report.

    JFYI, Tag attributes could use a reference for Field for the DataSource provided from that particular Node/Tag name.

    We have updated your FlexReport according to your Xml data. Please refer for the same: SampleReport.zip

    Note: Make sure the flexreport file and xml data file should be on same folder/directory while running report.

    Best Regards,

    Nitin

  • Posted 14 September 2022, 9:11 pm EST

    Hello @GrapCity Team,

    I have a query regarding report’s field generation in flxr .

    Can we filter out information that is to be shown in the report somehow for the xml tags that are repetitive instead of rendering all of them in the report ?

    For example :

    Now , the flxr will take the data source as “Observation” .

    In the report , i want to show only the name and value (or) only the value attributes

    of Observation node for which the name = “firstObservation” .

    Is this achievable ?

    PFA and help us out if this can be done.

    ObseravationReport.zip

  • Posted 15 September 2022, 9:37 pm EST

    Hi Bharat,

    Thanks for the sample report.

    In order to show detail where name=“firstObservation” only, you need to write VB Script for Detail.OnFormat as:

    
    If name = "firstObservation" Then
      Detail.Visible = True
    Else
      Detail.Visible= False
    EndIf
    
    

    Please refer the attached modified sample for the same : ObseravationReport_Mod.zip

    Note: Make sure the flexreport file and xml data file should be on same folder/directory while previewing report in FlexReportDesigner.

    Best Regards,

    Nitin

  • Posted 2 October 2022, 3:47 pm EST

    Hello @Grapecity team,

    New query.

    The below is the sample xml

        <GrossingObservationDetails type="pc" subtype="Diagnosis">
          <Observation name="DiagnosisType" value="Others" />
          <Observation name="code" value="New Diagnosis003" />
          <Observation name="interpretation" value="Summary3  SUmmary33." />
          <Observation name="MicroscopicNotes" value="Mic Note3  Mic Note33  Mic Note333" />
          <Observation name="ReportToCancerRegistry" value="false" />
          <Observation name="abnormalcellsaneploidevents" value="" />
          <Observation name="abnormalcells9p21deletions" value="" />
          <Observation name="IsAbnormal" value="False" />
        </GrossingObservationDetails>
    

    Is there a feasibility to write a VBScript in the VBScriptEditor section on a flex report for the below scenario

    Need to display all the Observation nodes only if its parent node GrossingObservationDetails attribute ( type =“pc” )

    Tried this using If Then condition on the Details.OnFormat of a flex report but it displays everything . newsample.zip

  • Posted 2 October 2022, 8:06 pm EST

    Hi Bharath,

    Your issue is different from this thread. Try creating a new case if you have a query with a different issue.

    However, we have created a support ticket and we will reply on the new support ticket for you. You can refer here: https://www.grapecity.com/my-account/my-support/case/fdfbb607-fa42-ed11-bba2-00224827e905

    Best Regards,

    Nitin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels