GrapeCity.ActiveReports.PageReport instance creation performance

Posted by: vmaryenko on 3 September 2021, 1:52 pm EST

  • Posted 3 September 2021, 1:52 pm EST

    Hello,

    Our company considering using ActiveReports to generate pdf reports.

    I created application according to this documentation: https://www.grapecity.com/activereportsnet/docs/v15/online/rendering-to-pdf.html

    AcitveReports template (xml report) is retrieved from database so this code is used:

    using StreamReader streamReader = …

    PageReport pageReport = new(streamReader);

    The thing is the creation of PageReport constructor that takes TextReader object as argument takes about 1 second and it’s to long for our application (we can process thousands of reports).

    I tried to use one PageReport instance for all reports but the parameters that I passed are not changed for the next reports. So when I use this code https://www.grapecity.com/forums/ar-dev/activereports-14-net-core- for the next reports the parameters that were passed to the first report are not cleared and all reports contain the same data.

    So my question is, are there any ways how to clear parameters that were passed to the first report or maybe some another approach how to increase performance?

  • Posted 4 September 2021, 12:19 am EST

    So I want to do something like that but all generated pdf reports have 0 value passed into the parameter in the first iteration:

    using Stream stream = GenerateStreamFromString(reportRdl);
                using StreamReader streamReader = new(stream);
                PageReport pageReport = new(streamReader);
    
                for (int i = 0; i < 1000; i++)
                {
                    foreach (ReportParameter parameter in pageReport.Report.ReportParameters)
                    {
                        if (parameter.Name == "ReportParameter1")
                        {
                            parameter.DefaultValue.Values.Clear();
    			/* Always 0 in all generated pdf reports*/
                            parameter.DefaultValue.Values.Add(i.ToString()); 
                        }
                    }
    
                    MemoryStreamProvider memoryStreamProvider = new();
                    pageReport.Document.Render(new PdfRenderingExtension(), memoryStreamProvider, new Settings());
    
                    Stream result = memoryStreamProvider.GetPrimaryStream().OpenStream();
                }
    

    Are threre any ways to clear parameters of the report without creation new PageReport instance?

  • Posted 20 September 2021, 5:04 am EST

    Hello,

    I believe your query was resolved through our support system. For the benefit of others, the solution was to clear the parameters from the Report’s document before setting its default value.

    for (int i = 0; i < 1000; i++)
    {
     pageReport.Document.Parameters.Clear();
    
     foreach (ReportParameter parameter in pageReport.Report.ReportParameters)
     {
        if (parameter.Name == "ReportParameter1")
        {
            parameter.DefaultValue.Values.Clear(); 
            parameter.DefaultValue.Values.Add(i.ToString()); 
        }
     }
    
Need extra support?

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

Learn More

Forum Channels