Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

mlreportgen.dom.Document.createTemplate

Package: mlreportgen.dom

Create DOM template file

Syntax

createTemplate(path)
createTemplate(path,type)

Description

createTemplate(path) creates a copy of the default DOM template file in the specified location. The file extension indicates the type of template file to create.

example

createTemplate(path,type) creates a template file of the specified type in the specified location. If the path does not have an extension, the method appends the extension .htmtx for HTML, .dotx for Word, pdftx for PDF, or .htmt for single-file HTML.

To use a template you created programmatically with Report Explorer, set these OPC core properties on the new template using mlreportgen.dom.Document.getCoreProperties and mlreportgen.dom.Document.setCoreProperties:

  • Description

  • Identifier

  • Title

Examples

collapse all

Create a Microsoft® Word template file in the current folder.

import mlreportgen.dom.*
Document.createTemplate('MyWordTemplate','docx');

Create a template. Apply the core OPC properties to it so that you can access the template in Report Explorer.

import mlreportgen.dom.*;

Document.createTemplate('pdf_template','pdf');
cp = Document.getCoreProperties('pdf_template.pdftx');
cp.Description = 'A pdf template for form-based reports';
cp.Identifier = 'mypdf-form-template';
cp.Title = 'My PDF Template';

Document.setCoreProperties('pdf_template.pdftx',cp);

Move the template to a folder on the MATLAB® path. To use the template in the current MATLAB session, update the template cache so that the template appears in Report Explorer.

rptgen.db2dom.TemplateCache.getTheCache(true);

If Report Explorer is already open, the new template appears as an option on the list of templates you can use. If the document conversion template editor was already open, close it and reopen it to see the new template.

Input Arguments

collapse all

Path for the template file you want to create, specified as a character vector. If you use the path argument without the type argument, include the template extension: .htmtx for HTML, .docx for Word, .pdftx, or .htmt for single-file HTML.

If you use both the path and type arguments, and you do not specify an extension for path, the createTemplate method adds the appropriate extension to the new template.

Type of template, specified as:

  • 'html' for HTML.

  • 'docx' for Word.

  • 'pdf' for PDF.

  • 'html-file' for single-file HTML. HTML output consists of a single file that contains the text, style sheets, JavaScript®, and images for the report.

The template type must match the type you specified using the path argument. If the path argument did not include an extension, the type argument determines the extension for this method to use.

Tips

Invoke createTemplate on the mlreportgen.dom.Document class, not on an instance of that class. In other words, use Document.createTemplate, not myDocument.createTemplate.

Introduced in R2014b

Was this topic helpful?