rptview

Display report or presentation

Description

example

rptview(domObj) displays the report specified by the input mlreportgen.dom.Document object in an appropriate viewer.

Note

The mlreportgen.report.Report class has a method named rptview. When you call rptview with an mlreportgen.report.Report object as the argument value, the method is invoked. For all other types of argument values, the rptview function is invoked. See Tips.

example

rptview(reportPath) displays the report specified by reportPath in an appropriate viewer, based on the file extension.

example

rptview(reportName,format) displays the report specified by reportName in an appropriate viewer, based on the format specified in format.

example

rptview(docxfile,'pdf') converts a Microsoft® Word report to PDF and displays the report in a PDF viewer.

example

rptview(pptObj) displays the presentation specified by the input mlreportgen.ppt.Presentation object in Microsoft PowerPoint®.

example

rptview(pptPath) displays the presentation located at pptPath in Microsoft PowerPoint.

Examples

collapse all

Display an HTML report that was generated using an mlreportgen.dom.Document object.

import mlreportgen.dom.*;
d = Document('mydoc');

p = Paragraph('Hello World');
append(d,p);

close(d);
rptview('mydoc');

Display a PDF report that was generated using an mlreportgen.dom.Document object.

import mlreportgen.dom.*;
d = Document('mydoc','pdf');

append(d, 'Hello World');

close(d);
rptview(d);

Display a report that was generated using an mlreportgen.report.Report object. Specify the path and file name of the report by using the value of the OutputPath property of the object.

import mlreportgen.dom.*;
import mlreportgen.report.*;
rpt = Report('myReport','docx');

p = Paragraph('Hello World');
add(rpt,p);
close(rpt);
rptview(rpt.OutputPath);

Use the rptview function to convert a Word report to PDF and display it in a PDF viewer.

import mlreportgen.dom.*;
import mlreportgen.report.*;
rpt = Report('myReport','docx');

p = Paragraph('Hello World');
add(rpt,p);

close(rpt);
rptview('myReport.docx','pdf');

Create two reports with the same name, but with different formats and content. Specify the format to display the appropriate report.

import mlreportgen.dom.*;
import mlreportgen.report.*
rpt = Report("myReport","html");

p = Paragraph("Hello World");
add(rpt,p);
close(rpt);

rptWord = Report("myReport","docx");
p = Paragraph("Hello again, World");
add(rptWord,p);
close(rptWord);

rptview("myReport","docx");

Display a presentation by calling rptview with the name of the mlreportgen.ppt.Presentation object.

import mlreportgen.ppt.*
ppt = Presentation("MyPresentation");
open(ppt);

slide1 = add(ppt,"Title and Table");
replace(slide1,"Title","Magic Square Slide 1");
replace(slide1,"Table",Table(magic(3)));
close(ppt);
rptview(ppt);

Display a presentation by calling rptview with the path and file name, including the extension, of the generated PowerPoint presentation.

import mlreportgen.ppt.*
ppt = Presentation("MyPresentation");
open(ppt);

slide1 = add(ppt,"Title and Table");
replace(slide1,"Title","Magic Square Slide 1");
replace(slide1,"Table",Table(magic(3)));
close(ppt);
rptview("MyPresentation.pptx");

Input Arguments

collapse all

Document object that generates the report to view, specified as an mlreportgen.dom.Document object.

Path and name of a specific report file, including the file extension, specified as a string scalar or character vector. You can use the OutputPath property of an mlreportgen.dom.Document object or an mlreportgen.report.Report object to provide reportPath.

The report file name extension determines the viewer in which the report displays.

File ExtensionViewer

.htmx

MATLAB® web browser

.html

MATLAB web browser

.zip

MATLAB web browser

.docx

Microsoft Word

.pdf

PDF viewer

Path and file name of a report, without the file extension, specified as a string scalar or character vector.

Report output format, specified as one of these values:

  • 'html'

  • 'html-file'

  • 'docx'

  • 'pdf'

Word .docx file to convert to PDF, specified as a Word file having a .docx extension.

Presentation object that generates the presentation to view, specified as an mlreportgen.ppt.Presentation object.

Path and name of a specific presentation file, including the file extension, specified as a string scalar or character vector. The file extension can be .pptx or .potx. You can use the OutputPath property of the mlreportgen.ppt.Presentation object to provide pptPath.

Tips

Calling rptview with an mlreportgen.report.Report object as the argument value, invokes the rptview method of the mlreportgen.report.Report object. The rptview method calls the rptview function with the value of the Document property of the report object as the argument value.

Calling rptview with an argument value other than an mlreportgen.report.Report object invokes the rptview function.

For example, in the following code, the first rptview call invokes the rptview method. The second rptview call invokes the rptview function.

import mlreportgen.report.*
rpt = Report('myReport','pdf');
add(rpt, 'Hello World');
close(rpt);
% Invokes rptview method
rptview(rpt);
% Invokes rptview function  
rptview('myReport.pdf');

Introduced in R2014b