mlreportgen.dom.DOCXPageHeader Class
R2026bNamespace: mlreportgen.dom
Page header definition for Microsoft Word document
Description
Use an object of the mlreportgen.dom.DOCXPageHeader class to add a header to the first page of a section or to odd pages, even pages,
or both.
This class is only compatible with this MATLAB®
Report Generator™ output type: "docx".
The mlreportgen.dom.DOCXPageHeader class is a handle class.
Creation
Description
creates a page header based on the default Word template.docxHeader = DOCXPageHeader
creates a page header for the specified type of page, that is, odd, even, or
first, based on the default Word template.docxHeader = DOCXPageHeader(pageType)
creates a page header for the specified type of page based on the specified
template.docxHeader = DOCXPageHeader(pageType,templatePath)
creates a page header for the specified type of page, based on the specified
document part template in the specified template.docxHeader = DOCXPageHeader(pageType,templatePath,docPartTemplateName)
creates a page header for the specified type of page, based on the specified
document part template used by the specified source. The source can be a
document or a document part.docxHeader = DOCXPageHeader(pageType,templateSrc,docPartTemplateName)
Input Arguments
Type of page header appears on, specified as one of these values:
default— Header for odd pages of the section, even pages if you do not specify an even-page header, and first page if you do not specify a first-page header.first— Header for first page of a section.even— Header for even pages in a section.
For example, to have a blank header appear on the first page
of a section and a different header appear on the other pages, define
two headers, one with pageType set to first and
the other with pageType set to default.
Full path of header template, specified as a string scalar or a character vector.
Data Types: char | string
Name of this part’s template if it is stored in a template
specified by the templatePath or templateSrc argument,
specified as a character vector or string scalar.
Document or document part object whose template contains the template for this document part,
specified as an mlreportgen.dom.Document object for a document or an
mlreportgen.dom.DocumentPart object for a document part.
Properties
ID of the current hole in the document, specified as a character vector or string scalar.
Attributes:
GetAccess | public |
SetAccess | private |
Transient | true |
NonCopyable | true |
Data Types: char | string
Type of the current template hole, specified as "Inline" or
"Block".
An inline hole is for document elements that a paragraph element can contain:
Text,Image,LinkTarget,ExternalLink,InternalLink,CharEntity, orAutoNumber.A block hole can contain a
Paragraph,Table,OrderedList,UnorderedList,DocumentPart, orGroupelement.
Attributes:
GetAccess | public |
SetAccess | private |
Transient | true |
NonCopyable | true |
Data Types: char | string
Since R2026b
Template holes mapped by ID number, returned as a dictionary mapping each hole ID in
the template to a hole content object. Use the hole ID as a key to access the
corresponding mlreportgen.dom.InlineHoleContent or
mlreportgen.dom.BlockHoleContent object, then call the
append method on the object to fill the hole with
content:
d.Holes("Title").append("My Report");
You cannot add, remove, or replace Holes dictionary entries.
Assigning a value to a hole entry or setting an entry to []
throws a MATLAB:class:SetProhibited error:
d.Holes("Title") = "My Report"; % Error: MATLAB:class:SetProhibited
An inline hole occurs in a paragraph. You can append only objects that a paragraph can contain, such as text and images. A block hole can contain block-level elements such as paragraphs, tables, and lists.
If your code calls moveToNextHole, fill each hole through
Holes before advancing past that hole. After
moveToNextHole advances past a hole, appending content to that
hole causes a holeContentCannotAppend error. For details, see mlreportgen.dom.InlineHoleContent or mlreportgen.dom.BlockHoleContent.
Attributes:
GetAccess | public |
SetAccess | private |
Data Types: dictionary
Current page layout of this document, specified as an
mlreportgen.dom.DOCXPageLayout object,
mlreportgen.dom.PDFPageLayout object, or []. This
property applies to Word and PDF documents. For Word documents, the value is a
DOCXPageLayout object that specifies the current page layout. For
PDF documents, the value is a PDFPageLayout object if the document
currently specifies a page layout. For HTML documents, the value is always
[].
Attributes:
GetAccess | public |
SetAccess | private |
Transient | true |
NonCopyable | true |
Type of page header appears on, specified as one of these values:
"default"— Header for odd pages of the section, even pages if you do not specify an even-page header, and first page if you do not specify a first-page header."first"— Header for first page of a section."even"— Header for even pages in a section.
For example, to have a blank header appear on the first page and a different header appear on
the other pages, define two headers, one with pageType set to
"first" and the other with pageType set to
"default".
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Full path of header template, specified as a string scalar or a character vector.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Parent of this object, specified as a document element object. A document element must have only one parent.
Attributes:
GetAccess | public |
SetAccess | private |
NonCopyable | true |
Children of this object, specified as an array of document element objects. This
property contains the document element objects appended using the
append method.
Attributes:
GetAccess | public |
SetAccess | private |
NonCopyable | true |
Tag, specified as a character vector or string scalar. The DOM API generates a
session-unique tag as part of the creation of this object. The generated tag has the
form CLASS:ID, where
CLASS is the object class and
ID is the value of the
Id property of the object. Use this value to help identify
where an issue occurs during document generation.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Object identifier, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Methods
Method | Purpose |
|---|---|
append |
Input Arguments
Return Values
To see a list of
the Document Object Model (DOM) class objects and MATLAB data types you can use as the
For more information, see the equivalent |
Close header | |
Fill template hole | |
Move to next template hole | |
Open header |
More About
You can append these DOM objects to an
mlreportgen.dom.DOCXPageHeader object:
You can append these MATLAB data types to an
mlreportgen.dom.DOCXPageHeader object:
character array — Appends and returns a
mlreportgen.dom.Textobjectstring scalar — Appends and returns a
mlreportgen.dom.Textobjectnumeric variable — Appends and returns a
mlreportgen.dom.Numberobjectlogical variable — Appends and returns a
mlreportgen.dom.Numberobject with a value of1or01D horizontal array of double values or strings — Appends and returns a
mlreportgen.dom.UnorderedListobject1D string array — Appends and returns a
mlreportgen.dom.UnorderedListobject1D categorical array — Appends and returns a
mlreportgen.dom.UnorderedListobject2D array of double values or strings — Appends and returns a
mlreportgen.dom.Tableobject2D array of strings — Appends and returns a
mlreportgen.dom.Tableobject2D categorical array — Appends and returns a
mlreportgen.dom.TableobjectMATLAB table — Appends and returns a
mlreportgen.dom.MATLABTableobject
Version History
Introduced in R2014bThe Holes property provides direct access to template holes by ID.
Use the hole ID as a dictionary key to access the corresponding hole content object, then
call the append method to fill the hole with content. This approach
eliminates the need to iterate through holes to find a specific ID.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)