slreportgen.report.RptFile class

Package: slreportgen.report

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 (MATLAB Report Generator))

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

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

Creation

Description

example

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.

reporter = RptFile(Name,Value) sets properties using name-value pairs. You can specify multiple name-value pair arguments in any order. Enclose each property name in single quotes.

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.

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 string or character array value specifies the path of a customized version of the default template for the output type to be generated.

Attributes:

GetAccess
public
SetAccess
public

Data Types: character array | string

Name of template for this reporter, specified as a character array 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: character array | string

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

Attributes:

GetAccess
public
SetAccess
public

Data Types: string | character array | object

Methods

expand all

Examples

Create a RptFile Reporter

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" 
 

Report on a Documentation Block

Use the RptFile reporter to report on a Documentation block in the sldemo_fuelsys Simulink model. The RptFile reporter uses a Report Explorer setup file to obtain information about the Documentation block.

Note

Before you run this example, use the Report Explorer to create a setup file named my_setup_file.rpt. The setup file for this example contains a hierarchy of a Model Loop, System Loop, Block Loop, Paragraph, and Documentation components as shown. Select the components from the middle pane.

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

  • Paragraph component is in the Formatting folder.

  • Documentation block component is in the Simulink Blocks folder.

For more information on setting up a setup file for this example, see Create a Report Setup File (MATLAB Report Generator).

Use this script to generate a report that includes information about the properties of the Sensor Info Documentation block in the ToController system of the sldemo_fuelsys model.

model = "sldemo_fuelsys";
load_system(model)

rpt = slreportgen.report.Report("MyReport","pdf");
chap = mlreportgen.report.Chapter("Report on a DocBlock");
 
rptFile = slreportgen.report.RptFile("my_setup_file.rpt");
rptFile.Model = model;
rptFile.System = "sldemo_fuelsys/To Controller";
rptFile.Block = "sldemo_fuelsys/To Controller/Sensor Info";

add(chap,rptFile);
add(rpt,chap);
 
close(rpt);
rptview(rpt);

Introduced in R2019a