Main Content

rptview

Display report or presentation

Description

example

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

To open a Word document on a Linux® or Macintosh platform, rptview calls the soffice command. On Linux, Apache® OpenOffice® or LibreOffice® must be installed. On Macintosh, Apache OpenOffice must be installed in the /Applications folder.

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.

Note

This functionality is only available on Microsoft Windows®. If you are running on a Macintosh or Linux platform, you must generate a PDF directly using the Report or DOM APIs.

example

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

To open a presentation on a Linux or Macintosh platform, rptview calls the soffice command. On Linux, Apache OpenOffice or LibreOffice must be installed. On Macintosh, Apache OpenOffice must be installed in the /Applications folder.

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 character vector or string scalar. 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® WebWindow

.html

MATLAB WebWindow

.zip

MATLAB WebWindow

.docx

Microsoft Word

.pdf

PDF viewer

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

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 character vector or string scalar. The file extension can be .pptx or .potx. You can use the OutputPath property of the mlreportgen.ppt.Presentation object to provide pptPath.

Limitations

  • rptview does not support viewing PowerPoint (.ppt) or Word (.docx) reports in MATLAB Online.

Tips

Note

If a mlreportgen.dom.Document object's OpenStatus property is 'open' and you call rptview to view the report, OpenStatus will be set to 'closed'. Displaying a report requires executing the DOM API's close command, which converts the report's in-memory DOM representation to a file of the type specified by the Type property. rptview issues the required close command for you if Document.OpenStatus is not ready set to 'closed' .

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');

Version History

Introduced in R2014b