Is it possible to use Report Generator to put dynamic text in the footer of a Microsoft Word document?
Can footers on different pages be different?
Best Answer
Using dynamic text in a footer is possible and it can be done in the same way any other text can be generated.
Attached is a very basic example that uses dynamic text in a footer with different values on different pages. It uses information from the examples in the following two links:
To use a custom-made Word template, create a new document using the "mlreportgen.dom.Document" constructor and set the "templatePath" property to your DOTX file. Here is the documentation for a Document object:
And here is a simple example using a custom-made template file from MS Word within the MALTAB Report Generator API:
import mlreportgen.dom.*
d = Document('MyWordDoc', 'docx', 'CustomTemplate.dotx'); %assuming template is in same folder; otherwise, specify full path
open(d);
append(d,'Hello World'); % add some text to generate doc
close(d);
rptview(d.OutputPath)
This formatting for headers and footers will disappear if you are adding chapters to the report. To customize chapter page headers, see the following documented examples for creating and editing chapter templates:
When creating a page footer, you can first specify which pages you would like it to appear on (first page only, even pages, odd pages, or all pages). Then, you can append different DOM objects to the footer, such as a page number or a paragraph.
The following code is an adaptation of the example linked above. This code demonstrates how to add a paragraph with custom text to a footer which already includes the page number:
Best Answer