Main Content

mlreportgen.report.HTMLModuleTabs Class

Namespace: mlreportgen.report
Superclasses: mlreportgen.report.Reporter

Create tabbed panels

Since R2020a

Description

An mlreportgen.report.HTMLModuleTabs reporter adds a widget consisting of a stack of tabbed panels (module tabs) to an HTML report. Selecting a tab displays the contents of the panel. Use this reporter to display related information in compact form.

Note

Use HTMLModuleTabs reporters only with HTML or single-file HTML reports.

The mlreportgen.report.HTMLModuleTabs class is a handle class.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

example

tabsObj = mlreportgen.report.HTMLModuleTabs creates an empty HTMLModuleTabs reporter. You must specify the tab labels and content using the TabsData property. Adding an empty HTMLModuleTabs reporter to a report produces an error.

tabsObj = mlreportgen.report.HTMLModuleTabs(Name=Value) sets properties using name-value pairs. You can specify multiple name-value pair arguments in any order.

Properties

expand all

Tab label and panel content, specified as an array of structures with these fields:

  • Label — Tab label, specified as a character vector, a string scalar, or an mlreportgen.dom.Text object. Use a unique label for each tab.

  • Content — Panel content, specified as one of these values:

    • A character vector or string scalar

    • A DOM object

    • A Report API reporter object

    Note

    To include multiple DOM objects on one tab, set the Content field to an mlreportgen.dom.Group object that contains the DOM objects.

Source of the template for this reporter, specified in one of these ways:

  • Character vector or string scalar that specifies the path of the file that contains the template for this reporter

  • Reporter or report whose template is used for this reporter or whose template library contains the template for this reporter

  • DOM document or document part whose template is used for this reporter or whose template library contains the template for this reporter

For an HTML report, the type of the template must be htmtx. For a single-file report, the type must be htmt.

Name of template for this reporter, specified as a character vector or string scalar. The template for this reporter must be in the template library of the template source (TemplateSrc) for this reporter.

Hyperlink target for this reporter, specified as a character vector or string scalar that specifies the link target ID or as an mlreportgen.dom.LinkTarget object. A character vector or string scalar value is converted to a LinkTarget object. The link target immediately precedes the content of this reporter in the output report.

Methods

expand all

Examples

collapse all

This example generates a single-file HTML report that has a separate tabbed panel for each system diagram of a Simulink® model.

This example requires Simulink and Simulink Report Generator™.

Run the following command to access the supporting files used in this example.

openExample('rptgenext/SimulinkReportGeneratorFilesExample');

Create the report and a chapter.

rpt = slreportgen.report.Report("MyReport","html-file");
open(rpt);

ch = mlreportgen.report.Chapter("sf_car System Diagrams Tabbed Image Gallery");

Load the model and find all the diagrams in the model.

model_name = "sf_car";
load_system(model_name);

finder = slreportgen.finder.DiagramFinder(model_name);
results = find(finder);

Create an mlreportgen.report.HTMLModuleTabs reporter to contain tabs that correspond to the diagrams. Specify the tab labels and content for each system diagram. The tab label is the system name. The tab content is the system diagram snapshot.

moduleTabs = mlreportgen.report.HTMLModuleTabs();
for result = results
    moduleTabs.TabsData(end+1).Label = result.Name;
    
    diag = result.getReporter();
    moduleTabs.TabsData(end).Content = mlreportgen.dom.Image(diag.getSnapshotImage(rpt));
end

Add the HTMLModuleTabs reporter to the chapter and add the chapter to the report. Close and view the report.

add(ch,moduleTabs);
add(rpt,ch);

close(rpt);
rptview(rpt);

The report opens with the content of the first tab visible. The first tab contains the top-level diagram of the model. To see a different diagram, click the corresponding tab.

This example generates tabbed panels where each panel contains a different type of content. The example also shows how to include multiple DOM objects in the content of a tabbed panel by grouping the DOM objects in an mlreportgen.dom.Group object.

Create a report and a chapter.

rpt = mlreportgen.report.Report("MyReport","html");
open(rpt);
ch = mlreportgen.report.Chapter("Tabs with Different Types of Content");

Create an HTMLModuleTabs reporter and specify the label and content for each tabbed panel. For the last panel, create a Group object that contains a paragraph and a table.

% Create group from a paragraph and a table
p = mlreportgen.dom.Paragraph('This is a table:');
t = mlreportgen.dom.Table(magic(2));
grp = mlreportgen.dom.Group;
append(grp,p);
append(grp,t);

% Create cell arrays for the labels and content
labels = {'Text','Paragraph','Link','List','Image','Group'};
content = {"This tab contains text as a string.",...
    mlreportgen.dom.Paragraph('This tab contains content using a DOM Paragraph.'),...
    mlreportgen.dom.ExternalLink("http://www.mathworks.com/","MathWorks"),...
    mlreportgen.dom.UnorderedList(["Coffee", "Tea", "Milk"]),...
    mlreportgen.dom.Image(which("ngc6543a.jpg")),...
    grp};

% Create a structure from the labels and content
tabsdata = struct('Label',labels,'Content',content);

% Create the HTMLModuleTabs reporter
modTabsObj = mlreportgen.report.HTMLModuleTabs('TabsData',tabsdata);

Add the HTMLModuleTabs reporter to the report. Close and view the report.

add(ch,modTabsObj);
add(rpt,ch);
close(rpt);
rptview(rpt);

The report opens with the content of the first tab visible.

tabs_ex2.png

Click the Group tab to see that it contains a paragraph and a table.

tabs_ex_2_group_tab.png

Version History

Introduced in R2020a