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!