mlreportgen.dom.DOCXSubDoc class

Package: mlreportgen.dom
Superclasses:

Reference to external Microsoft Word document

Description

Reference to external Microsoft® Word document.

Construction

docxSubDocObj = DOCXSubDoc() creates an empty document reference.

docxSubDocObj = DOCXSubDoc(path) creates a reference to a Word document at the specified path. Appending this reference to a Word document (the master document) inserts a link to the subdocument at the point at which the reference is appended.

Opening a master document in Word causes the link to the subdocument to be displayed, instead of its content. To replace the link with the content, select Expand Subdocuments from the Outlining tab of the View tab on the Word toolstrip.

The rptview command expands subdocuments when it opens a Word document. You can also use docview to expand and unlink subdocuments.

Input Arguments

expand all

Path of document targeted by this reference, specified as a character vector.

Output Arguments

expand all

Path of Word document targeted by this reference, represented by an mlreportgen.dom.DOCXSubDoc object.

Properties

expand all

ID for this document element, specified as a character vector. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

Tag for the document element, specified as a character vector.

The DOM generates a session-unique tag when it creates the document element. Structure the tag as class:id, where class is the class of the element and id is the value of the Id property. You can specify a tag to replace the generated tag. Specifying your own tag can make it easier to identify where an issue occurred during document generation.

Path of document targeted by this reference, specified as a character vector. Use ASCII characters. Use the following format for specifying a full path involving a mapped drive.

'file:///C:/UserPath/FileName.docx'

Methods

Method

Purpose

clone

Use DOCXSubDoc.clone in a similar way to how you use Paragraph.clone.

Clone this Word document reference.

Examples

collapse all

import mlreportgen.dom.*

info = Document('CompanyInfo','docx');
append(info,'XYZ, Inc., makes widgets.');
close(info);

infoPath = info.OutputPath;

rpt = Document('Report','docx');
open(rpt);

append(rpt,Paragraph('About XYZ, Inc.'));

append(rpt,DOCXSubDoc(infoPath));

close(rpt);
rptview(rpt.OutputPath);