Can you preview a report without closing it?

32 views (last 30 days)
I would ideally like to regularly preview the appearance of a report without needing to regenerate the entire thing, however executing rptview() closes the report so it can no longer be edited.
Any report based object (report, chapter, etc) seems to use the same pointer since modifying one modifies both, so something like below would not work, as it closes both reports.
rpt2 = rpt;
rptview
In theory you could generate two parallel reports, but attempting to append the same object to multiple reports leads to an error as well.
import mlreportgen.report.*
import mlreportgen.dom.*
rpt = Report('test 1','pdf');
rpt2 = Report('test 2','pdf');
tp = TitlePage;
tp.Title = 'Title';
append(rpt,tp);
append(rpt2,tp);
Error using mlreportgen.report.ReporterBase/getImpl
Cannot add this reporter to report /test 2.pdf because it has also been added to report
/test 1.pdf.
In which case you'd have to make separate instances of everything you want to add to the report.

Accepted Answer

Sandeep Mishra
Sandeep Mishra on 4 Dec 2024 at 6:56
Hi Randolph,
I noticed that you are using MATLAB Report Generator to generate reports in PDF format and want to perform the following two tasks: preview the report without closing it and append the same object to multiple reports.
Addressing your first query:
Regarding the second query:
import mlreportgen.report.*
function tp = createTitlePage(titleText)
import mlreportgen.report.*
tp = TitlePage;
tp.Title = titleText;
end
% Create and use title pages in reports
rpt1 = Report('test1', 'pdf');
append(rpt1, createTitlePage('Title for Report 1'));
rpt2 = Report('test2', 'pdf');
append(rpt2, createTitlePage('Title for Report 2'));
I hope this helps you in resolving your queries!
  1 Comment
Randolph Leiser
Randolph Leiser on 4 Dec 2024 at 19:16
Thanks Sandeep, I appreciate your reply. It seems the fastest/cleanest way to do what I want is using copyfile and running the alternate version without interfering with the main script. I was hoping there might be a more clever way to handle this, but for my current purposes this will serve.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!