Main Content

slreportgen.report.RptFile Class

Namespace: slreportgen.report
Superclasses: slreportgen.report.Reporter

Create Report Explorer-based reporter

Description

Use the RptFile reporter to include the content generated by a Report Explorer setup (.rpt) file in a Report API report. When added to a report, the RptFile reporter:

  1. Executes the specified Report Explorer setup file to generate a DocBook XML rendition of the Report Explorer report

  2. Uses a modified version of the Report Explorer Docbook-to-DOM conversion template to convert the XML to a set of DOM objects (see Manage Report Conversion Templates)

  3. Adds the DOM content to the Report API report.

Tip

Use a Block Loop rather than a Chart Loop component in your report setup file to report on Stateflow® charts. See Report on Stateflow Dialog Snapshots.

The slreportgen.report.RptFile class is a handle class.

Creation

Description

reporter = RptFile creates an empty Report Explorer-based RptFile reporter. Before adding the reporter to a report, your report program must set the reporter's SetupFile property to the path of a Report Explorer setup (.rpt) file. Otherwise, an error occurs.

By default, the RptFile reporter uses a conversion template that is a slightly modified version of the Report Explorer's default conversion template for the report output type. For example, if the report output type is PDF, the reporter uses a slightly modified version of the default template for the Report Explorer's PDF (from template) output type.

You can use a custom conversion template to customize the reporter output. Use the reporter's createTemplate method to create a copy of one of the reporter's default output-type-specific conversion templates for customization. To use the customized template, set the RptFile reporter's TemplateSrc property to the path of the customized template.

example

reporter = RptFile(SetupFile) creates a RptFile reporter based on the specified Report Explorer setup file (.rpt file). See the SetupFile property.

example

reporter = RptFile(Name=Value) sets properties using name-value arguments. You can specify multiple name-value arguments in any order.

Properties

expand all

Report Explorer setup file path, specified as a character array or string. Do not use form-based reports for setup files that you use with the RptFile reporter. The Report API report to which the setup file is added overrides the output type of the setup file.

Attributes:

GetAccess
public
SetAccess
public

Data Types: string | character array

Model name, specified as a character array or string, of the model for which the specified SetupFile is executed. If the setup file contains a Model Loop, the RptFile reporter sets its value to the value of this property. An error occurs if the setup file does not contain a Model Loop or contains multiple model loops.

Attributes:

GetAccess
public
SetAccess
public

Data Types: character array | string

System path, specified as a character array, string, or slreportgen.finder.DiagramResult object. If the setup file contains a System Loop, the RptFile reporter sets the System Loop's value to the value of this property if it is a character or string. If the value is a DiagramResult object, the reporter sets the System Loop to the value of the result's Path property. An error occurs if the setup file does not contain a System Loop or contains multiple system loops.

Attributes:

GetAccess
public
SetAccess
public

Data Types: character array | string | object

Block path, specified as a character array or string, slreportgen.finder.DiagramElementResult object, or slreportgen.finder.BlockResult object for a block. If the setup file contains a Block Loop, the RptFile reporter sets the Block Loop's value to the value of this property if it is a character or string. If the value is an slreportgen.finder.BlockResult object, the reporter uses the value of the object's BlockPath property. If the value is a DiagramElementResult object, the reporter uses the value of the object's DiagramPath and Name properties to determine the full path. An error occurs if the setup file does not contain a Block Loop or contains multiple block loops.

Note

Use a Block Loop component in your setup file to report on Stateflow charts. See Report on Stateflow Dialog Snapshots.

Attributes:

GetAccess
public
SetAccess
public

Data Types: character array | string | object

Source of conversion template to be used by this reporter to convert the setup file's XML output to DOM objects. An empty value specifies use of the default template for the output type of the report to be generated. A character vector or string scalar value specifies the path of a customized version of the default template for the output type to be generated.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Name of template for this reporter, specified as a character vector or string. By default this property specifies RptFile, the name of the reporter's default template. This default template resides in the template library of its default conversion template along with other templates used to convert Report Explorer XML components to DOM objects. The default reporter template contains a single hole named Content to be filled with the DOM content converted from the XML content generated by the setup. If you change the name of this template, you must set this property to the new name. You can modify the template itself, but the modified template must contain a hole named Content.

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

Create an RptFile reporter without specifying a setup file. Then, use the SetupFile property to specify the Report Explorer setup file.

reporter = slreportgen.report.RptFile();
reporter.SetupFile = "my_setup_file.rpt"

This example shows how to report on a documentation block in the sldemo_fuelsys Simulink® model.

The setup file docblock_setup_file.rpt contains a Model Loop, a System Loop, a Block Loop, a Paragraph, and a Documentation component. When you create a setup file, you can select these components from the middle pane of the Report Explorer:

  • The Model Loop, System Loop, and Block Loop components are in the Simulink section.

  • The Paragraph component is in the Formatting section.

  • The Documentation component is in the Simulink Blocks section.

Setup file containing a hierarchy of a Model Loop, System Loop, Block Loop, Paragraph, and Documentation components.

Create a Simulink report.

rpt = slreportgen.report.Report("MyReport","pdf");

Load the model.

model_name = "sldemo_fuelsys";
load_system(model_name)

Create a chapter.

chap = mlreportgen.report.Chapter("Report on a DocBlock");

Use the report setup file to report on the properties of the Sensor Info block in the ToController system of the model.

rptFile = slreportgen.report.RptFile("docblock_setup_file.rpt");
rptFile.Model = model_name;
rptFile.System = "sldemo_fuelsys/To Controller";
rptFile.Block = "sldemo_fuelsys/To Controller/Sensor Info";
add(chap,rptFile);

Add the chapter to the report.

add(rpt,chap);

Close and view the report.

close(rpt);
rptview(rpt);

Report showing Chapter 1 "Report on a DocBlock", followed by information about properties of the Sensor Info Documentation block.

This example shows how to report on Stateflow dialog snapshots by using a Block Loop component in a Report Explorer setup file.

The setup file sf_setup_file.rpt contains a Model Loop, a System Loop, a Block Loop, and a Stateflow Dialog Snapshot component. When you create a setup file, you can select these components from the middle pane of the Report Explorer:

  • The Model Loop, System Loop, and Block Loop components are in the Simulink section.

  • The Stateflow Dialog Snapshot component is in the Stateflow section.

Setup file containing a hierarchy consisting of a Model Loop, System Loop, Block Loop, and Stateflow Dialog Snapshot component.

Create a Simulink report.

rpt = slreportgen.report.Report("MyReport","pdf");
open(rpt);

Load the model.

model_name = "sf_car";
load_system(model_name);

Create a chapter.

chap = mlreportgen.report.Chapter();
chap.Title = strcat(model_name,": Stateflow Dialog Snapshots");

Find the systems in the model.

sys_finder = slreportgen.finder.SystemDiagramFinder(model_name);
systems = find(sys_finder);

Find the blocks in the current system. Use the report setup file to report on the Stateflow dialog snapshots.

for system = systems
    blk_finder = slreportgen.finder.BlockFinder(system);
    blocks = find(blk_finder);

    for block = blocks
        if slreportgen.utils.isValidSlSystem(block.Object) && ...
                ~isempty(slreportgen.utils.block2chart(block.Object))
            rptFile = slreportgen.report.RptFile("sf_setup_file.rpt");
            rptFile.Model = model_name;
            rptFile.System = system;
            rptFile.Block = block;
            add(chap,rptFile);
        end
    end
end

Add the chapter to the report.

add(rpt,chap);

Close and view the report.

close(rpt);
rptview(rpt);
close_system(model_name)

Version History

Introduced in R2019a