Convert text into template
|Top Previous Next|
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.
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.
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);
if Band.Alias = 'ANAME' then
Abort := TRUE;
Now you can insert a data band and assign the 'Alias':
Note: If you assign a string to property 'Name', this text will be displayed instead of 'Data'