ActiveReports v15: How to load xml header into designer

Posted by: ewan.johnstone on 12 April 2022, 2:57 am EST

    • Post Options:
    • Link

    Posted 12 April 2022, 2:57 am EST

    Greetings,

    I am currently trying to integrate Active Reports Designer into a web app with the intent of editing Report headers which are stored in a database as XML.

    The desktop equivalent (from active reports v9, which is what our desktop app uses) is the method which looks like arDesigner.loadReport(xmlReader, DesignerReportType.Section).

    For the web case what I have gathered currently from the documentation is that first I need to use UseCustomStore from the aspnet Designer service, which requires me to write an implementation of IResourcesService. This has a method GetReport which is called by the front end and which is used to get the Report to be displayed in the designer.

    However this method returns a Report object but currently the only way I know how to loadXml into a Report is via the LoadLayout method of the SectionReport object, but I can’t figure out any way of getting a Report from a SectionReport.

    I tried using ReportExtension.FromXML() but my XML is not in the right format

    Currently my implementation of GetReport looks like the following:

    
    Stream stream = _reportApp.GetHeaderXMLFromDatabase(dto.Mode);	//db access code
    
    			SectionReport sReport = new SectionReport();
    			using (XmlTextReader reader = new XmlTextReader(stream))
    			{
    				sReport.LoadLayout(reader);
    			}
    			//from here I need to get a Report object somehow
    
    

    Is there any way to get this approach to work? Can I get from a SectionReport to Report or am I barking up the wrong tree and need to do something like UseFileStore in this case?

  • Posted 12 April 2022, 2:58 am EST

    Example of the XML I am loading from the db (I didn’t included in the first post because it was being marked as spam)

    
    <?xml version="1.0" encoding="UTF-8"?>
    <ActiveReportsLayout Version="3.2" PrintWidth="9637.92" DocumentName="ActiveReports Document" ScriptLang="C#" MasterReport="0">
      <StyleSheet>
        <Style Name="Normal" Value="font-family: Arial; font-style: normal; text-decoration: none; font-weight: normal; font-size: 10pt; color: Black; text-align: left; vertical-align: top; ddo-char-set: 1" />
        <Style Name="Heading1" Value="font-family: Arial; font-size: 16pt; font-style: normal; font-weight: bold" />
        <Style Name="Heading2" Value="font-family: Times New Roman; font-size: 14pt; font-style: italic; font-weight: bold" />
        <Style Name="Heading3" Value="font-family: Arial; font-size: 13pt; font-style: normal; font-weight: bold" />
      </StyleSheet>
      <Sections>
        <Section Type="Detail" Name="Detail" Height="0" BackColor="16777215" />
      </Sections>
      <ReportComponentTray />
      <PageSettings LeftMargin="1138" RightMargin="0" TopMargin="1138" BottomMargin="1138" />
      <Parameters />
    </ActiveReportsLayout>
    
    
  • Posted 13 April 2022, 7:09 pm EST

    Hello Ewan,

    ActiveReports Web Designer does not support designing Section Reports. If you want to design report in a web application then I would suggest you to either use RDL or Page Reports.

    Regards,

    Akshay

  • Posted 13 April 2022, 8:50 pm EST

    Hi Akshay,

    I see, thank you for your response, though I am not familiar enough with Active Reports to know how to do the approach you suggest.

    Would you be able to link me to some documentation which outlines how I can do this?

  • Posted 17 April 2022, 9:50 pm EST

    Hi Ewan,

    > Would you be able to link me to some documentation which outlines how I can do this?

    Editing Section reports in the web designer is not supported in ActiveReports, which is why I suggested you to use other reporting types.

    To learn more about RDL and Page Reports please refer to the following links:

    Regards,

    Akshay

  • Posted 9 May 2022, 2:57 am EST

    Hi Akshay,

    From reading the documentation it sounds like I need to migrate the xml-based section reports to make it compatible with the web designer. In the first link it says,

    “For XML-based RPX reports we have an import tool, which allows migrating most of the layout.”

    However I cannot find any further information on this tool. Would you be able to point me to instructions on how I can migrate these section reports xmls?

    Thanks,

    Ewan

  • Posted 9 May 2022, 9:55 pm EST

    Hi Ewan,

    Please refer to the following page of our documentation:

    https://www.grapecity.com/activereportsnet/docs/latest/online/importing-rpx.html

    Please note there are some limitations when converting XML-based Section Reports to RDL/Page Reports. The limitations are mentioned in the above URL as well.

  • Posted 10 May 2022, 1:38 am EST

    Hi Akshay,

    Thank you for the information. I think I have enough information now to proceed.

  • Posted 10 May 2022, 8:00 pm EST

    Hi Akshay,

    Just one final question. Is the import wizard the only way of converting section reports? Is there no way of doing it at runtime via the .net code? That would save our customers having to convert their headers themselves.

  • Posted 12 May 2022, 5:46 pm EST

    Hi Ewan,

    Yes, you can convert the report at runtime as well. For this you would need to reference the following assembly:

    C:\Program Files (x86)\GrapeCity\ActiveReports 16\Tools\ GrapeCity.ActiveReports.Imports.Rpx.dll and use the RpxConverter class to convert the report to RDL.

    For reference, I have shared a sample application along with.

    RPXConvertToRDL.zip

  • Posted 12 May 2022, 7:45 pm EST

    Hi Akshay,

    Thanks for this! That’s very useful.

  • Posted 16 May 2022, 3:18 am EST

    Hi Akshay,

    Unfortunately I am having trouble getting the import dll to work.

    I have added the dll to my project and used the convert as in the example you gave but when I run it at the line:

    PageReport pageReport = converter.ConvertToRdl(report, true);

    I get the error: “The type initializer for ‘GrapeCity.ActiveReports.Imports.Rpx.I.’ threw an exception.”

    System.NullReferenceException

    HResult=0x80004003

    Message=Object reference not set to an instance of an object.

    Source=GrapeCity.ActiveReports.Imports.Rpx

    StackTrace:

    at GrapeCity.ActiveReports.Imports.Rpx.I..(Stream )

    Any idea as to what is causing this?

    Also I cannot run the example you provided as it uses v16 but I only have a license for v15.

  • Posted 16 May 2022, 5:11 pm EST - Updated 30 September 2022, 7:19 am EST

    Hi Ewan,

    You can convert the sample to ActiveReports 15 by using the conversion tool. This will replace all the dlls with your installed ActiveReports 15 version. Please refer to the attached screenshot. Note you might have to make some additional changes in the code as well.

    I have attached an ActiveReports 15 sample as well.

    Also, I was unable to replicate the issue with the sample report in the example. Are you having the same issue with the attached sample report, as well? Please share your report file that you are having issue converting so we can replicate this behavior on our end.

    RPXConvertToRDLAr15.zip

  • Posted 17 May 2022, 9:13 pm EST

    Hi Akshay,

    The example you sent works fine for me, even when I swap out the report that comes with it for my own. Conversely I get the same error in my project even when I load the report that comes with your example. When I create a Section report object and don’t load a layout but try to convert it, with your example I get a “cannot convert” error but with mine I still get an “Object reference not set to an instance of an object” error.

    My best guess is that the dll hasn’t loaded properly in my project but I am unable to diagnose the problem further. The only relevant difference between your project and mine is yours is .net framework whereas mine is .net standard (the former dependencies are shown under references whereas mine are under assemblies and packages. Though I don’t think this should make a difference.

    I have attached an example of the file I’m trying to convert though as stated above I don’t think the file is at fault since I can convert it without error with the code you supplied. Though the resulting file is blank but that’s a separate issue.

    Edit: apparently the file didn’t attach but it is the same xml that I posted earlier in the thread so it doesn’t matter.

  • Posted 18 May 2022, 7:57 pm EST

    Hello Ewan,

    After discussing this issue with the PMs on providing Import tool dlls compatible for .Net core or .Net Standard. It seems the best possible solution would be to just way for ActiveReports 16.2 release as we are planning on adding Section Report Editor support in Web Designer. We are planning release ActiveReports 16.2 before the end of September. But ultimately waiting for 16.2 would be a much better solution for you as RPX → RDLX conversion isn’t completely accurate and using this approach you are likely to run into issues especially doing so at runtime.

    When the feature would be fully implemented we may be able to send them an early beta build to help you get up and running as soon as possible if necessary although we don’t recommend using a beta build in production.

    If you cannot wait for the new release we can consider offering you the source code for the RPX → RDLX converter which would allow you to adapt it for your application scenario, but this is not approved yet and will require some internal discussion. We also would not be able to provide support in terms of working with the source code.

    >> Edit: apparently the file didn’t attach but it is the same xml that I posted earlier in the thread so it doesn’t matter.

    The above XML when opened in the Standalone designer creates an empty report with only a detail section with Height = 0, which why the exported RDL Report’s Body component and the bandwidth control has height 0 and have no other controls.

  • Posted 18 May 2022, 10:11 pm EST

    Hi Akshay,

    I see. Thank you for this information. I have passed this information on to my project manager. I’ll post here again if we have any further questions.

  • Posted 19 May 2022, 6:05 pm EST

    Hi Ewan,

    Sure, Looking forward to hear back from you soon.

  • Posted 25 August 2022, 7:35 pm EST

    Hi Akshay,

    Any update on when Active reports v16.2 will be released?

  • Posted 29 August 2022, 1:08 am EST

    Hi Ewan,

    Here’s the link to download ActiveReports 16.2.0:

    https://cdn.grapecity.com/ActiveReports/ar16/ActiveReports-v16.2.0.msi

    We have also updated our samples to ActiveReports 16.2.0 as well. You may download the samples using the following link:

    https://github.com/activereports/WebSamples16/tree/main/WebDesignerSamples

  • Posted 5 September 2022, 2:55 am EST

    Hi Akshay,

    Does the web samples above cover section reports? I couldn’t find anything though I’m sure I’m just not looking in the right place.

    How is section report editor support in Web Designer handled in the new code?

  • Posted 6 September 2022, 9:23 pm EST

    Hi Ewan,

    All the changes are made in the NuGet Packages for ActiveReports 16.2 and in the WebDesigner.js file which is why there isn’t much difference in the code in the above samples. You can load XML-Based Section Report(.rpx) in the Web Designer just like you would load a Page Report(.rdlx).

  • Posted 7 September 2022, 1:42 am EST

    Hi Akshay,

    Please elaborate on what you mean when you say to load it like you would a Page Report.

    As you’ll recall, I’m attempting to use the CustomStore to load my Section reports from xml stored in a database, but the GetReport method requires a Report object be returned. Previously I tried converting from Section Report to Report (is this the same as .rdlx?) but that didn’t work. So how can I proceed? What has been added in 16.2 that solves my issue?

  • Posted 8 September 2022, 6:35 pm EST

    Hi Ewan,

    I checked out the WebDesigner_CustomStore sample and you are right. There are changes to be made in the GitHub samples. To load SectionReports using a custom store a you are required to implement the * "ISectionResourcesService "

    interface which you can find in the * “GrapeCity.ActiveReports.Aspnetcore.Designer.Services”

    namespace. Similar to the * "IResourceService "

    interface that is used to get Page/RDL Reports.

    I have modified the sample myself and attached it along with. I have also requested the concerned team to update the web samples for the same.WebDesigner_CustomStore.zip

  • Posted 8 September 2022, 11:20 pm EST

    Hi Akshay,

    Thanks for this. This looks to be exactly what I’ve been looking for.

    One (hopefully) final question. I want to load a section report using the custom store automatically when the web designer first loads. Previously I did this by passing a path into the reportInfo property of the designer options, like so

    
    const params = stringify({ mode: props.mode });
        const reportPath = `Report/${0}/${params}/${false}`;
        const options = (window as any).GrapeCity.ActiveReports.WebDesigner.createDesignerOptions();
        options.reportInfo = { id: reportPath, name: reportPath };
    
    

    However this now doesn’t seem to hit the api and I get 404 errors.

    Reading the documentation (https://www.grapecity.com/activereportsnet/docs/latest/online/loading-reports-in-jsviewer-wd.html

    I see that the new code equivalent is the document object, however passing the above path in to id doesn’t seem to hit the load SectionReport endpoint either. The documentation seems to say this is only for loading reports that exist in the resources folder.

    So I was wondering if you could advise on what I need to do to call the custom store on first load?

    FYI: the url called by the designer currently looks like:

    https://localhost:44379/ar/reports/Report%2F0%2F{“mode”%3A1}%2Ffalse/content?type=rpx

    Note I am using the custom url prefix ‘ar’

    Thanks!

  • Posted 12 September 2022, 7:41 pm EST

    Hi Ewan,

    For loading reports into the Web Designer you may use the document object mentioned in the page you mentioned above only.

    Code:

        GrapeCity.ActiveReports.Designer.create('#ar-web-designer', {
        document: {
            id: 'RPX/Invoice.rpx',
            type: { platform: 'rpx', type: 'report' },
        }
    

    The id value requires a report id which is stored in the Custom Store. As per the error message the report id ‘Report%2F0%2F%7B%22mode%22%3A1%7D%2Ffalse’ do not exist in your CustomStore. I would suggest you to add a break-point in the GetSectionReport(string id) method and open the report using the Open button in the designer appbar. When the break-point is hit please check what is the actual report id that you wanted to call.

    For reference I have also attached a sample project in the sample I am using the document api to load the report into the designer. Also, if you open a SectionReport manually using the File option at top of the designer component the break point will hit which will help you check the report id that is being called.

    I hope this will help you get the correct report id and to modify your code accordingly.

Need extra support?

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

Learn More

Forum Channels