Display Reports
The Report API and DOM API rptview
functions allow you to display a
generated report in an appropriate viewer:
The Microsoft® Word software for Word documents
An HTML browser for HTML reports
A PDF viewer for PDF reports
If an HTML report is in zipped format, rptview
unzips
a copy of the report in your temporary folder and displays the report's main HTML
document in your default system browser.
To simplify your code, use the document output path as the argument to
rptview
. This example shows how to write your report program so
you change only the value of the doctype
variable to change the
output type.
import mlreportgen.dom.*; doctype = 'pdf'; d = Document('mydoc',doctype); p = Paragraph('Hello World'); append(d,p); close(d); rptview(d.OutputPath);
Alternatively, you can specify the rptview
function with two
arguments:
The path of the report — If you specify the file extension, you do not need to specify the second argument for output type.
The output type —
'html'
,'pdf'
, or'docx'
.Use
'pdf'
with a report formatted for Word to convert the Word document to PDF and open it in a PDF viewer.