Main Content

mlreportgen.report.HTMLModuleTabs Class

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

Create tabbed panels

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

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.

example

tabsObj = mlreportgen.report.HTMLModuleTabs(Name=Value) sets properties using name-value arguments. You can specify multiple name-value 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.

Attributes:

GetAccess
public
SetAccess
protected

Data Types: struct

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 this reporter uses or whose template library contains the template for this reporter

  • Document Object Model (DOM) document or document part whose template this reporter uses or whose template library contains the template for this reporter

The specified template must be the same type as the report to which you append this reporter. For example, for a Microsoft® Word report, TemplateSrc must be a Word reporter template. If the TemplateSrc property is empty, this reporter uses the default reporter template for the output type of the report.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Name of the 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 specified by the TemplateSrc property of this reporter.

Attributes:

GetAccess
public
SetAccess
public

Data Types: char | string

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

Attributes:

GetAccess
public
SetAccess
public

Methods

expand all

Examples

collapse all

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

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.

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

Close and view the report.

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.

Report showing an image gallery with eight tabs. The first tab shows the top-level diagram of the model sf_car.

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