Programmatically generating Report Generator
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
hey, i want to Export the results(Images and Text) of my mfile into a pdf-Report. I did it for the first Test and it works fine. But when i use a Loop to generate many Reports and save them in a Folder it didn't work.The code i could write can be use only for one Report or Image. it should look like this in the folder:
- report1
- report2
if true
import mlreportgen.report.*
import mlreportgen.dom.*
rpt = Report('Test','pdf');
tp=TitlePage;
tp.Title = 'Fehlerbericht des BNSE-Tests';
tp.Author = 'Idriss Moffo';
add(rpt,tp);
ch1 = Chapter();
ch1.Title = 'Störszenario: Menuesprung';
sec1 = Section;
sec1.Title = 'Last Image';
imageObj1 = Image(which('A.png'));
imageObj1.Height = '3in';
imageObj1.Width = '5in';
add(sec1,imageObj1);
add(ch1,sec1);
add(rpt,ch1);
close(rpt);
rptview(rpt.OutputPath);
end
0 Kommentare
Antworten (1)
Rahul Singhal
am 14 Mai 2018
Hi,
From the code it seems that the output report name is always kept the same. So if you generate multiple reports in a loop while keeping the output report name same, the generated report will be overridden in every loop iteration and hence you will see only one PDF report at the end. To fix this, just update the report name in every loop iteration using a counter. Below is a sample code:
% Specify a counter variable before the loop
counter = uint8(0);
% Start of the loop
for a = 1:10
% Your code in the loop
if true
% Your code ....
% Increament the counter and use it to create report name
counter = counter + 1;
rpt_name = strcat('report', int2str(counter));
% Create the report using this report name
rpt = Report(rpt_name,'pdf');
% Rest of the code ....
end
end % End of the loop
Siehe auch
Kategorien
Mehr zu Create Report Programs Using the Report API finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!