Convert text into template

<< Click to Display Table of Contents >>

Navigation:  Programming > WPReporter >

Convert text into template

One unique strength of our WPReporter concept is the possibility to convert an existing report (maybe you used to create it using OLE before) quickly into a report template.

 

You can use the procedure ConvertLetterIntoTemplate. This procedure creates a report with header and footer bands which are initialized to create the header and footer texts found in the original document. Around the body of the document a group is created which makes it easy to create many letters in a row.

 

Also see:

Token to Template Conversion

General Syntax - Fields

Syntax Highlighting

Bands

Groups

Parameters for Fields

Parameters for Bands and Groups

Example Template

 

1) All texts which are fixed have to remain in the template

 

2) All text blocks which depend on selected data must be replaced by mail merge fields.

 

3) Tables can be converted into groups with the utility function SuperMerge.ConvertTableIntoGroup. This utility can be called from within the report editor dialog. The tool can be used when the cursor is inside of a table, please do not select the table.

 

                    clip0151

 

clip0149    

clip0150

Sometimes it is a good idea to simplify the table before you use "ConvertTableIntoGroup". Very useful will be the API 'SplitTable' to split up a table which contains data from different logical elements.

 

4) Make text blocks conditional:

 

Please add a possibility to the application to set the Name of a band. i.e. you can use a combo box or popup menu.

 

The code would be basically:

if WPSuperMerge1.Bands.CurrentBand<>nil then

   WPSuperMerge1.Bands.CurrentBand.Alias := 'ANAME';

 

With the OnPrepareText event You can then check text bands (the green ones). If the band uses a certain Alias (alternatively You can use property Name) You can set the variable 'Abort' depending on a certain condition.

 

procedure TWPRepTest.WPSuperMerge1PrepareText(Sender: TWPSuperMerge;

 Band: TWPBand; Count: Integer; var ParProps: TParagraphProperty;

var Abort: Boolean);

begin

if Band.Alias = 'ANAME' then

begin

    Abort := TRUE;

end;

end;

 

Now you can insert a data band and assign the 'Alias':

 

clip0152

 

Note: If you assign a string to property 'Name', this text will be displayed instead of 'Data'