Tutorials to .com

Tutorials to .com » Software » Delphi » Serialization FastReport

Serialization FastReport

Print View , by: iSee ,Total views: 42 ,Word Count: 578 ,Date: Wed, 26 Aug 2009 Time: 10:17 AM

The original report in the development of a plug-in, because of the need remote transmission, requiring serialization statements, serialization FastReport There are two ways,

1. Only the sequence data, subject to termination by the customer data, and present reports, this approach requires the client is stored report format file xxx.Frf,

2. FastReport serialization of the result set (ie, received data can be saved as a frp file), so frf files do not exist on the client. I tend to use this way, after all, the lighter the better the client.

Simple to open a table will be followed by fr generate the results stored as frp and found a 64k large, which can not be tolerated, this is just the 2xx data only, but this issue is resolved is also very simple, compressed (only 4K), d7 There comes a compact unit zLib, As zlib usage is very simple, it offers Stream and the string of compression. Here is not said, and since this issue is resolved, Jiusheng serialization code

Serialization of the process is simple, in fact, understand the fr several important ways, the very simple and got the following results:

In the server-side

frReport1.Dataset: = FrDbDataset1; / / Set the Dataset property of frReport
FrDbDataset1.DataSet: = Adoquery1; / / link frDbDataset and Dataset instance
AdoQuery1.Open; / / access to data
frReport1.LoadFromFile ( 'd: \ 1.frf'); / / load a report format file
frReport1.PrepareReport; / / implementation of the report, data are not indicative of
frReport1.SavePreparedReport ( 'd: \ 3.frp'); / / save the results of a report into a document

/ / Load 3.frp, can get serialized data, but this to access the hard drive, bad mood. SavePreparedReport look at the code

procedure TfrReport.SavePreparedReport (FName: String);
var
Stream: TFileStream;
begin
Stream: = TFileStream.Create (FName, fmCreate);
EMFPages.SaveToStream (Stream);
Stream.Free;
end;
In this case, to see EMFPages whether it is public, it seems that it can, then we can change the final

Stream: = TMemoryStream.Create;
EMFPages.SaveToStream (Stream);

result: = Stream;

Client

More simple, you do not need any data set, even frReport instance of the class can also be dynamically generated,

with TfrReport.Create (nil) do
begin
try
LoadPreparedReport ( 'd: \ 2.frp'); / / you can change the form of the above stream, with EMFPages
ShowPreparedReport;
finally
Free;
end;
end;


In the solution of this problem, you can learn a few main methods FastReport

PrepareReport / / make statements obtained data from the data set

ShowPreparedReport / / display the data have been reports, the difference between attention and ShowReport, in fact, take a look at the implementation of ShowReport understand)

LoadPreparedReport / / load a result from the frp

SavePreparedReport / / save the results into a file

LoadFromFile / / reflected in the statements format file


Delphi Tutorial Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.