Documentation

Simplify Filling in Forms

The object-oriented approach allows you to use the DOMfillmethod to simplify form-based reporting. Thefillmethod is intended for instances of classes derived from themlreportgen.dom.Documentormlreportgen.dom.DocumentPartclass. It assumes that for each hole in a document or document part template, the derived class defines a method having this signature:

fillHoleID(obj)

TheHoleIDpart of the signature is the ID of a hole defined by the document or document part template. Theobjargument is an instance of the derived class. For example, supposed that a template defines a hole namedAuthor. Then the derived class defines a method namefillAuthorto fill theAuthorhole. Assuming that the derived class defines methods for filling the holes, thefillmethod moves from the first hole in the document or part to the last, invoking the correspondingfillHoleIDmethod to fill each hole.

Thefillmethod 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 partfillmethod. For example, suppose that you have derived a report class, nameMyReport, from themlreportgen.dom.Documentclass 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

More About

Was this topic helpful?