Can you preview a report without closing it?

조회 수: 2 (최근 30일)
Randolph Leiser
Randolph Leiser 2024년 12월 3일
댓글: Randolph Leiser 2024년 12월 4일
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.

채택된 답변

Sandeep Mishra
Sandeep Mishra 2024년 12월 4일
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
Randolph Leiser
Randolph Leiser 2024년 12월 4일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Code Verification에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by