WPReporter Events

<< Click to Display Table of Contents >>

Navigation:  Programming > WPReporter >

WPReporter Events

Reporting with WPReporter is controlled by events. This makes it possible to work with any database system, or also without a database, for example if load calculated data.

 

Within the event code you can check the properties of the object WPSuperMerge.Stack to get information about the current position within the report template. The property Stack.Previous can be used to check the properties of the parent group of bands. Other useful properties are Stack.GroupBand, Stack.Band and Stack.CurrentParagraph.

 

This events are published by the class TWPSuperMerge:

 

OnMailMergeGetText - the most important event, it is used to insert the data for certain data fields.

 

This event uses the same parameters like the TWPRichText event OnMailMergeGetText. In the simplest case the event handler can be

 

procedure TForm1.DoMailMergGetTexte(

 Sender: TObject; const inspname: string;

  Contents: TWPMMInsertTextContents);

begin

 Contents.StringValue := 'This is a test';

end;

 

It is possible, for example, to use this field name to retrieve the text from a data set:

 

Contents.StringValue := DataSet.FieldByName(inspname).AsString;

 

You can also change the attribute of the inserted text using 'MergeAttr'.

 

   Contents.MergeAttr.SetColor(clRed);

 

 

BeforeProcessGroup:

 

This event is the second most important. It is used to control if a group should be processed or not. If the group should be processed set the parameter ProcessGroup to true, if it should be not processed set the parameter ProcessGroup to false. If you know that this would be the last time this group is being used set the parameter IsLastRun to true.

 

When the template uses nested groups the BeforeProcessGroup will be triggered for the nested group before AfterProcessGroup is triggered for the outer group.

 

Typically you test the DataSet for being at the end (EOF) and set the parameter ProcessGroup accordingly:

if Band.Alias = 'MAIN' then ProcessGroup := not MainDataSet.EOF;

 

OnPrepareHeader:

 

This event is triggered before a header band is being processed. You may set the parameter Abort to true to skip the band.

 

OnPrepareText:

 

This event is triggered before a text band is being processed. You may set the parameter Abort to true to skip the band.

 

OnPrepareFooter:

 

This event is triggered before a footer band is being processed. You may set the parameter Abort to true to skip the band.

 

OnPostProcessBandData:

 

This event makes it possible to modify a paragraph after it was created in the destination text buffer. It is triggered after the entire text for a band was created. The start and end paragraphs are passed to the event. The paragraph references can refer to normal paragraphs or table row paragraphs. You can use this event to add flags to paragraphs to mark certain areas in the report.

 

AfterProcessGroupData:

 

This event is processed after the data bands in a group have been processed. You can use it to sum up values which should be used as totals in footers. AfterProcessGroupData will be triggered each round the group is used. You can set WPSuperMerge.Stack.PagebreakAtGroupEnd = true inside this event to force a pagebreak after the group data.

 

AfterProcessGroup:

 

This event is the triggered  after a group has been processed. Typically you use this event to advance to the next record in the database.

 

if Band.Alias = 'MAIN' then MainDataSet.Next;