Clone page

I have designed a report R1 with 1 page. My program usually uses this single page report for printing. This works just fine.


However, now the program needs to have some sort of plot series support. In this context this means that I want to use the before mentioned report R1 as a template for a new report R2 which shall consist out of N clones of that single page of the original report R1.

All of this must happen dynamically. I'm using C++ and FastReport 6.8 Standard. Report R1 stores its data in the Print form's dfm and I'm using TfrxPreview on this form.


The problem is: I can't find any documentation on how to do that and all I tried resulted in blank reports or crashs.

Essentially I need the functionality "clone R1.page1 (incl. all element names so that I can fill it with data appropriately), append that page to R2"


Thanks in advance for any help!

Comments

  • This is what I'd expect to work, but it doesn't:


    TfrxReport *R1; // the pre-designed source report, contains 1 content page

    ...

    auto R2=std::make_unique<TfrxReport>(nullptr);

    R2->AssignAll(R1);

    // now R2 is a clone of R1, with 1 content page, so far so good.

    ..

    // now I try adding clones of R1.page1 to R2

    auto source_page=R1->Pages[1];

    // auto source_page=R2->Pages[1]; // note: since R2 is a clone of R1 this should do too, but same result

    auto newpage=new TfrxReportPage(R2,R2); // add a new blank page to R2. Works.

    newpage->AssignAll(sourcepage); // try to clone sourcepage into that blank new_page. Doesn't work.


    However, what I end up is lots of blank pages instead of clones of the 1st page of R1. Looks as if AssignAll has no effect.

  • Okay, I managed to get it working.


    First of all, I was conceptually wrong. What I wanted was appending my single-page report to another destination-report.

    I found https://www.fast-report.com/en/blog/353/show/ but unfortunately it didn't work for me. The reason was that I used report->Preview and not the built in preview dialog.

    The workaround was to temporarily set report->Preview to null, otherwise the preview would only contain one page again...


    auto stored_preview=report->Preview;

    report->Preview=nullptr;

    // now do what the above blog tells you to do. And then restore report->Preview right before ShowPreparedReport

    report->Preview=stored_preview;

    report->ShowPreparedReport();

  • Try to set TfrxReportPage.PageCount

  • @gpi

    On which page would I do that? But anyway, even if that worked that would essentially just replace one workaround by the other. The point is that the blog example works differently / doesn't work depending on the report->Preview attribute. IMHO that's a bug.

  • IMHO create small demo project with "bug" and send it to support@fast-report.com

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.