Simplify Filling in Forms
The object-oriented approach allows you to use the DOMfill
method to simplify form-based reporting. Thefill
method is intended for instances of classes derived from themlreportgen.dom.Document
ormlreportgen.dom.DocumentPart
class. It assumes that for each hole in a document or document part template, the derived class defines a method having this signature:
fillHoleID(obj)
TheHoleID
part of the signature is the ID of a hole defined by the document or document part template. Theobj
argument is an instance of the derived class. For example, supposed that a template defines a hole namedAuthor
. Then the derived class defines a method namefillAuthor
to fill theAuthor
hole. Assuming that the derived class defines methods for filling the holes, thefill
method moves from the first hole in the document or part to the last, invoking the correspondingfillHoleID
method to fill each hole.
Thefill
method eliminates the need for a report program to loop explicitly through the holes in a document or document part's template. The report need only invoke the document or partfill
method. For example, suppose that you have derived a report class, nameMyReport
, from themlreportgen.dom.Document
class and that this derived class defines methods for each of the holes defined by the report template, based on data supplied in its constructor. Then, you need only three lines to generate an instance ofMyReport
:
functionmakeReport(rptdata) rpt = MyReport(rptdata); fill(rpt); close(rpt);
For an example of a forms-based, object-oriented report program, in theExamplespane of theMATLAB®Report Generator™documentation, open theObject-Oriented Reportexample.
See Also
Functions
Classes
Related Examples
- Use Subforms in a Report
- Fill the Blanks in a Report Form
- Create a Microsoft Word Template
- Add Holes in a Microsoft Word Template
- Create an HTML or PDF Template
- Add Holes in HTML and PDF Templates