Package: mlreportgen.report
Superclasses:
Section reporter
Create a section reporter that adds a section to the report. This class inherits from
mlreportgen.report.Reporter
.
section = Section()
creates a reporter that generates a report
section. You can add the section reporter to a report, chapter, or another section. If
you add a section to a report, the section starts on a new, portrait page with default
margins and a page number in the footer. The page number equals the previous page number
plus one. If you add the section to a chapter or another section, the reporter creates a
subsection that continues on the current page. The size of the title diminishes by
default with the depth of the section in the report hierarchy up to five levels deep.
Titles of sections lower than 5 are not numbered and have the same font size as level 5.
section = Section(title)
creates a report section containing a
section title with the specified title text. A hierarchical section number prefixes the
title text by default. For example, the default number of the first subsection in the
second chapter is 2.1. The font size of the title diminishes by default with the depth
of the section in the report hierarchy up to five levels deep.
sets properties using name-value pairs. You can specify multiple name-value pair
arguments in any order. Enclose each property name in single quotes.section
= Section(Name,Value
)
add | (Not recommended) Add content to section |
append | Add content to section |
createTemplate | Create section template |
customizeReporter | Create custom section reporter class |
getClassFolder | Section class definition file location |
getTitleReporter | Create a section title reporter |
number | Set section numbering |
copy | Create copy of reporter object and make deep copies of property values that reference a reporter, ReporterLayout, or DOM object |
customizeReporter | Create class derived from Reporter class |
getImpl | Get implementation of reporter |
This example adds a title and image to two sections and adds the sections to a chapter.
import mlreportgen.report.* import mlreportgen.dom.* rpt = Report('My Report','pdf'); append(rpt,TitlePage('Title','My Report')); append(rpt,TableOfContents); ch = Chapter('Images'); append(ch,Section('Title','Boeing 747', ... 'Content', Image(which('b747.jpg')))); append(ch, Section('Title','Peppers', ... 'Content',Image(which('peppers.png')))); append(rpt,ch); close(rpt); rptview(rpt);
This example uses a DOM Text
object to define the title. By using
the DOM object, you can set its properties and override the default black color of
the section title.
import mlreportgen.report.* import mlreportgen.dom.* rpt = Report('New Report','pdf'); open(rpt) sect = Section; sect.Title = Text('A Section'); sect.Title.Color = 'blue'; append(rpt,sect); close(rpt) rptview(rpt)
This example generates a report that sets the subsection titles to center alignment.
import mlreportgen.report.* import mlreportgen.dom.* rpt = Report('My Report','html'); append(rpt,TitlePage('Title','My Report')); append(rpt,TableOfContents); chTitle = Heading1('Chapter '); chTitle.Style = {CounterInc('sect1'),... WhiteSpace('preserve')... Color('black'),... Bold, FontSize('24pt')}; append(chTitle,AutoNumber('sect1')); append(chTitle,'. '); sectTitle = Heading2(); sectTitle.Style = {CounterInc('sect2'),... WhiteSpace('preserve') ... HAlign('center'),PageBreakBefore}; append(sectTitle,AutoNumber('sect1')); append(sectTitle,'.'); append(sectTitle,AutoNumber('sect2')); append(sectTitle,'. '); title = clone(chTitle); append(title,'Images'); ch = Chapter('Title',title); title = clone(sectTitle()); append(title,'Boeing 747'); append(ch,Section('Title',title,'Content',... Image(which('b747.jpg')))); title = clone(sectTitle()); append(title,'Peppers'); append(ch,Section('Title',title,'Content',... Image(which('peppers.png')))); append(rpt,ch); close(rpt); rptview(rpt);