Programmatically generating Report Generator
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Rahul Singhal
el 14 de Mayo de 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
Ver también
Categorías
Más información sobre Create Report Programs Using the Report API en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!