How to speed up report creation and design

Stimulsoft Reports.NET discussion
Post Reply
Claudio Maccari
Posts: 12
Joined: Fri Jun 09, 2006 11:53 am
Location: Italy

How to speed up report creation and design

Post by Claudio Maccari »

I need to use a complex object as data source of my report.
For details about the object please refer UML diagram posted here http://forum.stimulsoft.com/Default.aspx?g=posts&t=81

Currently I'm binding a List.
What can I do for speed up report generation & design.

This the code to show preview:

Code: Select all

public void Preview(object data, TemplateEnum template)
        {
            StiReport r = new StiReport();
            r.StopFactor = 0;            
            Template t = templateManager.Read(template);
            r.RegData(t.Description, data);
            r.Load(t.File);
            r.Render();
            stiPreviewControl1.Report = r;
            this.ShowDialog();
        }
This the code to load designer:

Code: Select all

public void Design(Template template,object data)
        {
            StiReport r = new StiReport();
            r.RegData(template.Description, data);
            r.Load(template.File);
            r.Design();
            template.File = r.SaveToByteArray();            
        }
The template (.mrt file) is stored in a database table.
Thank you for your help.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

How to speed up report creation and design

Post by Vital »

You can use one way to increase report rendering speed - compile the report under the first start only. When start the report on execution we check if preparing assembly with report if there is that immediately loads the report from this assemblies by method StiReport.GetReportFromAssembly. If no, than compile report by method report.Compile("report.dll") and build further. In next time beside us already will ready report in dll.

Example:

Code: Select all

string reportName = "MyReport.mrt";
string reportDllName = "MyReport.dll";

StiReport report = null;

// if assemblies of the report no on disk
if (!File.Exists(reportDllName))
{
  // load report from file
  report = new StiReport();
  report.Load(reportName);
  // compile report to assembly
  report.Compile(reportDllName);
}
else  // if assembly exist
{
// … use it
  report = StiReport.GetReportFromAssembly(reportDllName);
}
report.Show();
For also you can optimize report engine initialization at start of your program:

Code: Select all

StiConfig.Load();
Thanks.
Claudio Maccari
Posts: 12
Joined: Fri Jun 09, 2006 11:53 am
Location: Italy

How to speed up report creation and design

Post by Claudio Maccari »

Thank you very much for your help.

Are you sure that this solution works for users that are not administrators of their computer?
If the report is compiled in the same directory of the exe ( for es. %PROGRAMFILES%\MyApp ) the users that are non-admin will get an error.Isn'it ?

Thk
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

How to speed up report creation and design

Post by Edward »

Thank you very much for your help.
Are you sure that this solution works for users that are not administrators of their computer?
If the report is compiled in the same directory of the exe ( for es. %PROGRAMFILES%\MyApp ) the users that are non-admin will get an error.Isn'it ?
Yes you are right. If account has no permission to write access to %PROGRAMFILES%\MyApp application will not be able to add *.dll files to this folder. Please try following solutions:

1. Distribute your application with already compiled reports.

2. Add xml-based Dataset for storing compiled reports or use additonal table/field from your dataset:

Code: Select all

//Compile to stream
report.Compile(stream);

//Load report from a stream
StiReport report = StiReport.GetReportFromAssembly(stream);
3. Save *.dll files to availiable path with enabled permissions to write.
Thanks!
Claudio Maccari
Posts: 12
Joined: Fri Jun 09, 2006 11:53 am
Location: Italy

How to speed up report creation and design

Post by Claudio Maccari »

Now I save the compiled report in the same database table of the .mrt file.
Unfortunately the report creation is still slow.
Using the debugger for step by step exection the istruction that take much time is
report.RegData("DataSourceName", data);

I use this code to create report preview
The t.Compiled property is a byte array that contain to compiled report.

Code: Select all

public void Preview(object data, TemplateEnum template)
{
Template t = templateManager.Read(template);                      
StiReport r = StiReport.GetReportFromAssembly(t.Compiled);
r.StopFactor = 0;                        
r.RegData(t.DataSourceName, data);                    
r.Render();
stiPreviewControl1.Report = r;
this.ShowDialog();
}
Post Reply