Storing and loading a report
You may store a report in the following ways:
Method | Description |
---|---|
in the application's resources (WinForms/Mono) | The typical scenario of using the Report, which we looked at before, uses this method. The StoreInResources property of the Report object is responsible for this. This property is set to true by default. This method has the following pros and cons:+ a report is embedded into your application, you don't need to deploy extra files; - if you need to change a report, you have to recompile your application. Loading a report is performed automatically. To do this, FastReport .NET adds a code into the InitializeComponent method of your form. |
in the .FRX file | This method is useful if you want to give your users the ability to change a report. In this case, set the report's StoreInResources property to false . To load the report from a file, use the Load method of the Report object: report1.Load("filename.frx"); |
in the database | You may store a report in the database, either as a string or in a blob-stream. To load the report from a string, use the LoadFromString method of the Report object. To load the report from a stream, use the overloaded version of the Load method: report1.Load(stream); . To support the load/save operations in the report designer, you need to replace the "Open File" and "Save File" dialogs in the designer. Read here how to do this. |
as a C#/VB.NET class | To work with a report as a class, design your report and save in to the .cs/.vb file. To do this, select "file type" in the "Save" dialog. The file type maybe either .cs or .vb - it depends on the script language in the report (it may be changed in the "Report|Options..." menu). Include that file into your project. This method has the following pros and cons: + you can work with a report as a class; + you may debug a report; + this is the only way to use a report in ASP.NET project running on medium trust environment; - you cannot edit such a report. To do this, you need the original .FRX file; - if you need to change a report, you have to recompile your application. To work with a report, create an instance of the report's class: SimpleListReport report = new SimpleListReport(); report.Show(); |