mlreportgen.report.RptFile Class
Namespace: mlreportgen.report
Superclasses: mlreportgen.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:
Executes the specified Report Explorer setup file to generate a DocBook XML rendition of the Report Explorer report
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)
Adds the DOM content to the Report API report.
The mlreportgen.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.
reporter = RptFile(SetupFile)
creates a RptFile
reporter based on the specified Report Explorer setup file (.rpt
file).
See the SetupFile
property.
sets properties using name-value pairs. You can specify multiple name-value pair arguments
in any order.reporter
= RptFile(Name=Value
)
Properties
Methods
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 = mlreportgen.report.RptFile();
reporter.SetupFile = "my_setup_file.rpt"
Add Syntax-Highlighted Code to a Report
Use the RptFile
reporter to add syntax-highlighting to code in a Report
API Report.
Note
Before you run this example, use the Report Explorer to create a setup file named
highlight_syntax.rpt
. The setup file for this example contains a
Preformatted component with this text in its edit box:
% To import the Report API namespace, use this command: %<code_var>
This code creates a Report API report that includes the
highlight_syntax.rpt
setup
file.
rpt = mlreportgen.report.Report("My Report","pdf"); chap = mlreportgen.report.Chapter... ("Include Report Explorer Report Using the RptFile Reporter"); sect1 = mlreportgen.report.Section... ("Highlighted Syntax Example"); % Evaluate the expression and assign it to the code variable evalin('base','code_var = "import mlreportgen.report.*"'); rptfile = mlreportgen.report.RptFile("highlight_syntax.rpt"); add(sect1,rptfile) add(chap,sect1) add(rpt,chap) close(rpt) rptview(rpt)
Version History
Introduced in R2019a