Mailmerge insert HTML table - repeat header, borders

  • I am using mailmerge in WPTools 7 to insert HTML tables into a document, it works very good except for two things that just wouldn't work:


    1. Repeat header of the table on subsequent pages

    2. paint borders only between rows not around the table.


    Any hint is very appreciated!


    Thanks


    Michael

  • Unfortunately it just wouldnt work:


    I store all content.mergepar in wpMailMergeGetText for all tables I insert. Either in wpMailMergeGetText and after completion of the merge both parentRow and parentTable are NIL.


    How can I find the table objects I merged into?

  • Sorry that I did not make it clear.

    A template is loaded as docx, all the variables are just test phrases and are marked as bookmarks and get overwritten. One of the variables will be overwritten by a complete table served as html. I was hoping to find that table (or tables) later in the process along with theit bookmark names to do additional formatting like repeating headers and cell lines.


    It would be great if I could somehow access the (table-)object that was created by the merge process.


    Thanks

    Michael

  • You have access to all the paragraphs and tables, rows and cells after the text was created or modified.


    You can enumerate the paragraphs in a loop with


    par := WPRichText.FirstPar;

    while par<>nil do

    begin

    ..

    par := par.NextPar;

    end;


    This will find all first level paragraphs and tables (not the rows). The rows are inside a table paragraph - use the ChildPar reference.


    For example see the wptools code, i.e. procedure TWPCustomRtfEdit.GetSelectedCells(All, Outer: TList); in WPCtrMemo.

  • Thanks. I created this loop and found the table(s). Sorry for bugging again, but I can not find out how to reformat the table to make the frst row recurring on subsequent pages and how to create grey lines between the rows. The examples worked with callbacks on page creation, this I cannot use here.


    Would you mind helping me out and showing how to:


    • using the "par" below make the first row recurring
    • optinally draw lines between the rows

    Thanks in advance


    Code
    1. par := wp.firstPar;
    2. while par <> nil do
    3. begin
    4. if par.IsTable then begin
    5. // And now, what's next?
    6. end;
    7. par := par.nextPar;
    8. end;

    Sorry

  • When you have a table you can loop the rows:


    row := par.ChildPar;

    while row<>nil do

    begin

    ...

    row := row.ParNext;

    end;


    Inside a row it is the same with cells, they are the children of the row.


    This are all references to TParagraph so you can use the sample code from the example (callback).


    BTW - in HTML there are no repeating headers.

  • So finally I nearly got everything how I want it. The last thing I need help with: How do I make the first row of the table the repeating header.?I did not find a WPAT code for that. Would you mind helping me with this? Thanks in Advance!




    P.S. I am aware of the fact, that HTML does not support repeating headers, I was jiust thining that one could use <th> for Headers that are repeated in the document.