Loading and saving a report

Top  Previous  Next

By default, a report is stored together with the project form, i.e. in a DFM file. In most cases nothing else is required and you would not need to take any action to load the report. If you decide to store a report form in a file or in a BLOB-field in a DB (which improves flexibility in that the report  can be modified without having to recompile the program) you would have to use “TfrxReport” methods for loading or saving the report:

 

function LoadFromFile(const FileName: String;

                     ExceptionIfNotFound: Boolean = False): Boolean;

 

Loads a report from the file with the specified name. If the second parameter equals “True” and the file is not found then an exception is raised. If the file is loaded successfully it returns “True”.

 

procedure LoadFromStream(Stream: TStream);

 

Loads a report from a stream.

 

procedure SaveToFile(const FileName: String);

 

Saves a report to a file with the specified name.

 

procedure SaveToStream(Stream: TStream);

 

Saves a report to a stream.

 

Report files are given the default extension “fr3”.

 

Examples:

 

Pascal:

 

frxReport1.LoadFromFile('c:\1.fr3');

frxReport1.SaveToFile('c:\2.fr3');

 

C++:

 

frxReport1->LoadFromFile("c:\\1.fr3");

frxReport1->SaveToFile("c:\\2.fr3");