How to copy a templatedocument into new created databand?

  • I want to create a new base document (WPRichTextSource) containing a number of templates (TWPRichText). These templates are documents that have reportgroups and bands within.
    How do I copy this templatedocument into the newly created databand ?

    Thanks in advance,
    Ad Franse


    procedure AppendText( template : TWPRichText; databasename : string );
    var mastergroup : TParagraph;
    var target : TParagraph;
    var source : TParagraph;
    var lNewPage : boolean;
    begin
    WPRichTextSource.CheckHasBody;
    wpsupermerge1.Source.cursor.Position := $7fffffff;
    lNewPage := wpsupermerge1.source.Cursor.Position > 0;
    mastergroup := WPSuperMerge1.AddReportGroup( databaseName, [wpCreateBorders ], nil, SetCellStyle, 2);
    mastergroup.IsNewPage := lNewPage;
    target := mastergroup.AppendChild(nil);
    target.ParagraphType := wpIsReportDataBand;
    // how do I add the contents of template (TWPRichText) to this reportdataband ?
    // note it is possible that this document contains also reportbands, headers and footers
    //
    end;

  • I partially solved it.

    For the textcopy I have used the text in blue. On the screen this looks ok, but when I do a WPSuperMerge1.execute afterwards, the masterband-group is not visible in the result window, but all group and bands embedded in the template-document are still visible !

    How is that possible ?

    Ad Franse

    • Offizieller Beitrag

    Hi,

    This is a good solution, but I would suggest to use

    mastergroup.LoadFromString( template.asAnsiString( 'WPTOOLS' ), 'WPTOOLS' );

    And add the databand later

    target := mastergroup.AppendChild(nil);

    Otherwise You have an unwanted nesting.

    Julian