Main Content

Create Report Containers

Create Report API Objects to Hold Content

Every Report API program must create an mlreportgen.report.Report object to hold report content. Use the mlreportgen.report.Report constructor to create a Report object.

If you use the constructor without arguments, the Report API creates a PDF document named untitled.pdf in the current folder. To specify a name and location, use the path name of the report as the first argument of the constructor.

You can specify the type of report to generate by using the type argument. You can specify the type as 'html', 'docx' (for Microsoft® Word), 'pdf' for PDF output, or 'html-file' for single-file HTML output.

This Report constructor creates a document object called myReport for Word output.

d = Report('myReport','docx');

Using the templatePath argument, you can specify the path name of a custom template to use as a basis for formatting the report. Specify a template path if you want to base your report on a custom template that defines the appearance and structure of your report. The template type must match the document type. For example, this report constructor creates a report object for Word output using the template myWordTemplate.dotx.

d = Report('myReport','docx','myWordTemplate');

Create DOM Document Objects to Hold Content

If you intend to use the DOM API alone (i.e., without using Report API objects) to generate a report, you must create an mlreportgen.dom.Document object to hold the report content. Use the mlreportgen.dom.Document constructor to create a Document object.

If you use the constructor without arguments, the DOM API creates an HTML document named Untitled.htmx in the current folder. To specify a name and location, use the path name of the report as the first argument of the constructor.

You can specify the type of report to generate by using the type argument. You can specify the type as 'html', 'docx' (for Microsoft Word), 'pdf' for PDF output, or 'html-file' for single-file HTML output.

This Document constructor creates a document object called myReport for Word output.

d = Document('myReport','docx');

Using the templatePath argument, you can specify the path name of the template to use as a basis for formatting the report. Specify a template path if you want to base your report on a custom template that defines the appearance and structure of your report. The template type must match the document type. For example, this Document constructor creates a document object for Word output using the template myWordTemplate.dotx.

d = Document('myReport','docx','myWordTemplate');

See Also

Classes

Functions

Related Examples

More About