How to add module tabs in each section in HTML file using mlreportgen.report.HTMLModuleTabs ?
조회 수: 5 (최근 30일)
이전 댓글 표시
I am getting error while adding module tabs in second section (second function ->fun2()) of the html-file.
import mlreportgen.report.*;
import mlreportgen.dom.*;
%create a output folder for report
mkdir output;
outPath = fullfile(pwd,'output','HTML_Report');
%report name
rpt = Report(outPath, 'html-file');
%open report
open(rpt);
toc = TableOfContents;
toc.Title = Text('Contents');
append(rpt, toc);
%title
tp = TitlePage('Title', 'KPI Summary',...
'subtitle', 'Post Processing and Analysis Report');
append(rpt, tp);
%first function
fun1(rpt);
%Second function
fun2(rpt);
close(rpt);
Now, I add one section in fun1 added moduletabs which is working fine.
function fun1(rpt)
import mlreportgen.report.*;
import mlreportgen.dom.*;
t = mlreportgen.dom.Table(magic(2));
labels = 'table 1.0';
content = t;
tabsdata = struct('Label',labels,'Content',content);
modTabsObj = mlreportgen.report.HTMLModuleTabs('TabsData',tabsdata);
s1 = Section('Physical_Configuration');
append(s1, Section('Radio Configuration'));
append(rpt, modTabsObj);
add(rpt, s1);
end
Now, in second function error seen while adding another moduleTabs.
function fun2(rpt)
import mlreportgen.report.*;
import mlreportgen.dom.*;
t = mlreportgen.dom.Table(magic(3));
labels = 'table 2.0';
content = t;
tabsdata = struct('Label',labels,'Content',content);
modTabsObj = mlreportgen.report.HTMLModuleTabs('TabsData',tabsdata);
s1 = Section('Measurements');
append(s1, Section('Plots'));
append(rpt, modTabsObj);
add(rpt, s1);
end
When I comment fun2, code run successfully but with fun2 I got error.
Please help me if anyone knows how to add moduleTabs in each section?
댓글 수: 0
답변 (1개)
Kannan
2022년 9월 28일
Please go through the following code (Lines 45 and 48 are modified) to check if the error still persists and that you are able to add multiple module tabs to the report.
import mlreportgen.report.*;
import mlreportgen.dom.*;
%create a output folder for report
mkdir output;
outPath = fullfile(pwd,'output','HTML_Report');
%report name
rpt = Report(outPath, 'html-file');
%open report
open(rpt);
toc = TableOfContents;
toc.Title = Text('Contents');
append(rpt, toc);
%title
tp = TitlePage('Title', 'KPI Summary',...
'subtitle', 'Post Processing and Analysis Report');
append(rpt, tp);
%first function
fun1(rpt);
%Second function
fun2(rpt);
close(rpt);
function fun1(rpt)
import mlreportgen.report.*;
import mlreportgen.dom.*;
t = mlreportgen.dom.Table(magic(2));
labels = 'table 1.0';
content = t;
tabsdata = struct('Label',labels,'Content',content);
modTabsObj = mlreportgen.report.HTMLModuleTabs('TabsData',tabsdata);
s1 = Section('Physical_Configuration');
append(s1, Section('Radio Configuration'));
append(rpt, modTabsObj);
add(rpt, s1);
end
function fun2(rpt)
import mlreportgen.report.*;
import mlreportgen.dom.*;
t = mlreportgen.dom.Table(magic(3));
labels = 'table 2.0';
content = t;
tabsdata = struct('Label',labels,'Content',content);
%modTabsObj = mlreportgen.report.HTMLModuleTabs('TabsData',tabsdata);
s1 = Section('Measurements');
append(s1, Section('Plots'));
%append(rpt, modTabsObj);
add(rpt, s1);
end
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!