Beiträge von hmuscroft

    Yes the code has worked perfectly with every version up to 5.18.7.

    I simply rolled back to 5.18.6 and it works fine again.

    If it helps at all, the error occurs after merging the first record. It always falls over on the 2nd iteration for some reason. I am already assigning the Src and Dest props as you suggest.

    Regards

    Julian,

    I'm having the same problem. I've just upgraded to 5.18.7 and am getting errors with the super merge component. It throws an Exception with the message :-

    "The paragraphs must not use different RTFDataProps!"

    Look forward to your help!

    Regards,

    Hedley Muscroft
    Pioneer Software

    Hi Julian

    We have switched from ReportBuilder and am now using WPReporter instead for for generating reports in our software. The flexibility of WPReporter is excellent and our users find it much easier to create/edit reports now.

    The big problem we have run in to however is performance issues when merging medium/large datasets.

    I've emailed you a sample project demonstrating the problem, as we can't post files in these forums. [As a side point have you seen Attachment Mod from http://www.opentools.de? I run a phpBB forum too (http://www.clinicofficeforum.co.uk) and use it to allow users to post files.]

    Anyway - the sample app was compiled with D7 and WPTools 5.18.6. You'll also need the free kbmMemTable (http://www.components4developers.com) if you haven't already got it.

    The sample dataset contains around 2000 names and addresses and the report simply prints them in a list.

    As you'll see, the progress seems to slow down exponentially and is reduced to a crawl towards the end of the report. Using WPReporter, this report takes about 30 secs on my PC compared to about 4-5 secs in ReportBuilder.

    Things get a lot worse when we have ~10,000 and a more complex report template. Some reports are taking about 10-15 minutes to produce!!!

    What I really need to know is how we can speed things up?

    I've taken a look at the TWPSuperMerge.Execute and TWPSuperMerge.ProcessPar, but it's pretty complex stuff! Look forward to your help!!!

    Kind Regards,

    Hedley Muscroft
    Pioneer Software

    Hi,

    I have a report which has a band in it with the wppNewPageAfter flag set.

    This works fine, unless specify wpDeleteFieldsInDestination in TWPSuperMerge.Options before the mailmerge, the pagebreaks disappear.

    Is the wpDeleteFieldsInDestination option perhaps removing the pagebreaks?

    Thanks.

    Hi Julian,

    Thanks for your reply. I don't think I explained it very well, so I've emailed you 3 rtf files which illustrate the problem.

    As you'll see, the template is a simple letter, but I've also put the recipients lastname in both the page header and footer and I merged it with 3 people (Allshaw, Andrews & Barratt)

    The header works fine, but the footer just shows the last person (Barratt) on all pages.

    My guess is that the "ConverLetterIntoTemplate" should put the header band above the group band rather than underneath it.

    Any suggestions?

    Thanks,

    Hedley

    Hi Julian,

    I haven't posted for a while, but have just gotten round to using the new "ConvertLetterIntoTemplate" routine.

    For the most part it works great, but there is a problem with pagebreaks! Obviously, we want a pagebreak to separate one letter from the next in the merged document.

    So I added the "include" line as below:-

    Code
    Result := BodyText.AppendNewPar(false);
        Result.ParagraphType := wpIsReportGroup;
        Result.ChildPar := groupdata;
        Include(GetBandForPar(Result).FOptions, wppNewPageAfter);

    This now inserts a page break after the GROUP band, but here's the problem...

    After calling "ConvertLetterIntoTempate", the original template is formatted like this...

    <Header1>
    <Header2 etc.>
    <Group start>
    document body
    <Group end> <- page break here
    <Footer1>
    <Footer2 etc.>

    This means that the page break splits up the original document and the footers appear on their own on a blank page!

    How can we modify the ConvertLetterIntoTemplate to insert a page break AFTER the footers?

    Thanks,

    Hedley

    Hi,

    Some of my report templates require 1 page per record, so I insert a page break just before the end of the group band. This works, but after WPSuperMerge.Execute() there is a blank page at the end of the merged document, which needs to be removed.

    Here's my code :-

    Code
    procedure RemoveLastPageIfEmpty(WPRichText : TWPRichText);
    begin
      if (WPRichText.LastPar <> nil) then
        Exclude(WPRichText.LastPar.prop, paprNewPage);
    end;

    The problem is that it doesn't work if there are one or more empty lines (or paragraphs) on the last page.

    How can I determine if the last page has no text and then delete it accordingly?

    Thanks,

    Hedley

    PS : Any idea when you'll release 5.17.3?

    OK - I've tried to implement this, but just a couple of problems :-

    Firstly...

    Code
    par := WPSuperMerge.Bands.SelectGroup(WPRichText, 'DATA');

    I'm guessing that you must have implemented SelectGroup as part of the TWPBandManager object, because this won't compile. Please can you provide the code for this routine?

    Secondly, the new code doesn't seem to insert the headers/footers correctly.

    If I start with...

    Header
    <"DATA" GROUP BAND>
    Record fields
    </"DATA" GROUP BAND>
    Footer

    ...and I select just one "auto-group" field - let's say "category", the result is this (new lines in bold)...

    Header
    <"DATA" GROUP BAND>
    <HEADER BAND>
    FieldName : Category
    <FOOTER BAND>
    Count : count
    <"Category" GROUP BAND>

    Record fields
    </"Category" GROUP BAND>
    </"DATA" GROUP BAND>
    Footer

    The problem is that this doesn't merge correctly! The new header and footer bands need to be INSIDE the new "category" group band rather than above it. Also, for the supermerge to work, there needs to be a DATA band above the actual "Record fields" data.

    So, the finished template needs to be like this :-

    Header
    <"DATA" GROUP BAND>
    <"Category" GROUP BAND> <- above the header band
    <HEADER BAND>
    FieldName : Category
    <FOOTER BAND>
    Count : count
    <DATA BAND> <- may need to add DATA band

    Record fields
    </"Category" GROUP BAND>
    </"DATA" GROUP BAND>
    Footer

    I have tried jiggling your code around but I can't seem to get the new bands to insert inside the new group (I can move them to after but not inside!!).

    Also, how do we check to see if a DATA band already exists above the record data, and insert one if necessary?

    I know I'm asking a lot Julian, but this kind of reporting functionality will make a superb component even better!

    Thanks again for all your help,

    Hedley

    Hi Julian,

    This is really a follow up to a previous question about selecting the contents of group bands (https://www.wpcubed.com/forum/viewtopic.php?t=1244).

    Basically, what I am trying to do is give the users a simple list report, and then give them the option of grouping the report on their choice of fields.

    e.g. the default report will be

    Code
    Header<DATA GROUP BAND>Record fields</DATA GROUP BAND>Footer

    and they can select a couple of fields to group the data on, and my code then needs to auto-format the report like this...

    I have written a test app which attempts to do this and is 90% of the way where, but I just need a little more help.

    I have emailed the sample app to "support@wptools.de" and I am more than happy for anyone else to have a copy of the source code if it helps. There are also a number of useful utility routines for TWPRichText and TWPSuperMerge in there.

    The point I am stuck at now is that I need the ability to remove the contents of a group band, but not the band itself.

    The problem is commented in the "InsertAutoGroup" routine in "uReportFuncs.pas".

    Thanks in advance,

    Hedley Muscroft
    Pioneer Software

    Hi Julian - thanks for your quick reply (as always).

    I have tried your suggestion, but the problem now is that the WPRichText.MergeText only merges the current dataset record rather than iterating through the records like supermerge does.

    I'm trying to offer my users a letter mail merge facility. They create a template letter and then select a list of contacts to send the letter.

    They need to be able to create 'normal' looking letter with 'normal' headers/footers and then merge the letter. Trying to get them to use the header/data/footer report bands will be too confusing for them (they're not very it literate!!).

    Is it possible to get WPRichText.MergeText to scroll through the dataset in sync with the SuperMerge?

    Alternatively, is it possible to manipulate their template document at runtime BEFORE the merge? e.g. [1] backup their template [2] create a header band and a footer band [3] copy text from their headers/footers into the appropriate band [4] perform the supermerge [5] restore their document?

    Which of the above is easier? Thanks.

    Thanks Julian

    Hi Julian,

    Thanks for your help so far on this. I am now using this code :-

    Code
    DestWPRichText1.Clear();
        DestWPRichText1.Header.Assign(WPRichText1.Header);
        DestWPRichText1.AsString := WPRichText1.AsString;
        DestWPRichText1.ClearBody();
        WPSuperMerge1.SetSourceDest(SrcRichText1.Memo.RTFData, DestWPRichText1.Memo.RTFData);
        WPSuperMerge1.Execute();

    This now correctly copies over the headers/footers to the destination document, but the SuperMerge component doesn't process merge fields in the header/footer - is it possible to fix this?

    Thanks.

    Hi,

    I want to be able to select all text (including tables) inside a specified group band.

    Here's my code thus far, which works fine unless there's a table immediately at the start of the group, in which case it fails to select anything. In fact, when there are one or more tables inside the group, this code doesn't work very well. Is there a better way to do this?

    Any help would be appreciated!

    Thanks in advance,

    Hedley

    Hi,

    I am using the WPSuperMerge component to create merged letters.

    The problem is that WPSuperMerge ignores normal headers and footers in the template document. I know that the correct way of doing this is to create a Header Band in the template, but I have hidden the band functionality from my users in order to make it as simple as possible for them.

    When the merge button is clicked, my code does this :-

    [1] backup their template letter (to a memstream)
    [2] creates a group band around their letter
    [3] inserts a page break at the end of the group
    [4] opens a new document and calls WPSuperMerge.Execute
    [5] restores their original letter

    This all works perfectly apart from the headers/footers.

    A possible work around would be for me to create a header band and a footer band in code, and then copy the template's header / footer into the correct bands, but I can't work out how to do this!

    Please help!

    Thanks,

    Hedley

    PS : Hope you had a good holiday, but I'm glad you're back!

    Wow - that was a quick reply!!! Thanks so much for your excellent support Julian.

    Just a quick follow up question: You mentioned about the WPSuperMerge.MailMergeGetText routine which lets us do this :-

    Code
    Contents.StringValue := Table1.FieldByName(inspname).AsString;

    I have some BLOB fields which actually hold RTF data, and others which store JPEG images. Please can you point me in the right direction as to how to merge those fields?

    Thanks.

    Hi Julian,

    I'm using WPTools (5) to allow my users to both create banded reports (using WPReporter) but also to do mail-merging.

    I've some code (based on the WPReporter_MasterClient demo) to handle the banded reporting using the WPSuperMerge and now I'm looking at doing the letter mail-merges.

    My question is - which should I use for this - WPMMDataProvider or WPSuperMerge? ...and what are the advantages / disadvantages of each?

    I've done some tests and it it seems that I can just let the users drop the mail-merge fields into a document, and then when they click "merge", I create a group band around their text and then just merge it as if it is a report. The group band then takes care of iterating through the records.

    But this approach excludes the use of the WPMMDataProvider component.

    What would you recommend as the best approach?

    Thanks,

    Hedley

    Just did a search on the WPTools 4 posts and found a possible solution which is to insert a page break in to the template, and then use...

    Exclude(WPRichText1.LastPar.prop, paprNewPage);

    ... on the resulting report.

    Is there a better way to do this which doesn't mess up the report template with page breaks?

    Thanks