Convert C1Report to Flexreport

Posted by: thomas.hayashi on 19 December 2019, 1:28 am EST

    • Post Options:
    • Link

    Posted 19 December 2019, 1:28 am EST

    This documentation gives 3 ways to convert:

    https://www.grapecity.com/blogs/3-ways-to-convert-your-c1report-to-flexreport

    1.Batch

    2.Upgrade through FlexReport Designer

    3.Changing code

    In my scenario, I need to do the 3rd way, but slightly different.

    Some context:

    There are many modules of the system that use C1Report and right now we are not migrating everything at once to FlexReport. The module that we are migrating to FlexReport adds a subreport generated by another module that works with C1Report only. In other words, I have a FlexReport trying to add a C1Report subreport.

    Is there a way to convert the a C1.C1Report.C1Report object to a C1FlexReport object in C# ? Or Is there a way to add this C1Report subreport in FlexReport ?

    I’m asking for alternatives, such as: export C1Report to X and import in FlexReport; A custom cast or is there an easier/safe way to pass field by field between these 2 ?

    Thanks

  • Posted 19 December 2019, 7:50 pm EST

    Hello,

    To use a C1Report as a subreport in FlexReport, you can simply add the C1Report file in the FlexReport instance and add that as a subreport in the SubreportField.

    ```

    C1FlexReport mainReport = new C1FlexReport();

    mainReport.Load(“…/…/Products.flxr”, “Products”);

            C1FlexReport subRpt = new C1FlexReport();
            subRpt.Load("../../Subreport.xml","New Report");
             //Access main report's SubreportField
            SubreportField subreportField = (SubreportField)mainReport.Fields["Field1"];
            subreportField.Subreport = subRpt;
    
            viewer.DocumentSource = mainReport;
    
    
    This has been shown in the attached application for your reference.   
    
    Regards,
    Esha
    [zip filename="prj_WPF_FlexReport.zip"]https://gccontent.blob.core.windows.net/forum-uploads/file-3119e0fc-7cb7-46d0-af74-23418d920864.zip[/zip]
  • Posted 19 December 2019, 11:03 pm EST

    Well… using your answer as an example and tweaking the code, I could reach the solution. Therefore, I’ll mark as the answer, but initially I didn’t have the information necessary to do a load in FlexReport.

    I was expecting something more like the following (only drafts):

    
    // This subReport was generated outside. I only have the C1Report object
    C1Report subReport = new C1Report();
    
    C1FlexReport mainReport = new C1FlexReport();
    mainReport .Subreport = (C1FlexReport)subReport ;
    
    

    or

    
    C1Report subReportC1 = new C1Report();
    subReport.export("raw/byte format");
    C1FlexReport subReportFlex= new C1FlexReport();
    subReportFlex.load("raw/byte format");
    
    C1FlexReport mainReport = new C1FlexReport();
    mainReport .Subreport = subReportFlex ;
    
    

    or

    
    C1FlexReport subReportFlex= new C1FlexReport();
    C1Report subReportC1 = new C1Report();
    foreach(C1.Report.Field fd in subReportC1.Fields)
    {
    	subReportFlex.Fields.Add((C1.Win.FlexReport.Field)fd);
    }
    
    C1FlexReport mainReport = new C1FlexReport();
    mainReport .Subreport = subReportFlex ;
    
    

    I think, I’m oversimplifying the steps here with a C1Report object. Are any of these approaches actually feasible ?

  • Posted 22 December 2019, 5:35 pm EST

    Hello,

    I would like to bring a few points to your notice:

    1. C1Report instance cannot be converted to a C1FlexReport instance in the said manner.
    2. We need to access the particular field that has to contain the subreport as one report can have multiple subreports.
    3. C1Report cannot be exported to FlexReport using any export filter or export method.
    4. After adding a blank FlexReport to the SubreportField, you can add individual fields to the subreport using the field properties as:
    subreportField.Subreport.Fields.Add(fd.Name,fd.Text,new Rect(fd.Left,fd.Top,fd.Width,fd.Height));
    
    

    However, this may not guarantee the exact location of the controls and the layout of C1Report, specially when you have a large number of fields in the subreport.

    Hence, it is suggested that you load the C1Report in a FlexReport instance (as a legacy report), to avoid losing any kind of consistency.

    Thanks,

    Esha

Need extra support?

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

Learn More

Forum Channels