mlreportgen.report.Section クラス
パッケージ: mlreportgen.report
スーパークラス: mlreportgen.report.Reporter
セクション レポーター
説明
レポートにセクションを追加するセクション レポーターを作成します。このクラスは mlreportgen.report.Reporter
から継承します。
mlreportgen.report.Section
クラスは handle
クラスです。
作成
説明
section = Section()
は、レポート セクションを生成するレポーターを作成します。セクション レポーターをレポート、章、または別の節に追加できます。レポートにセクションを追加すると、既定の余白とページ番号付きのフッターが設定された縦向きの新規ページで、セクションが開始されます。ページ番号は、前のページ番号に 1 を加えたものになります。セクションを章または別の節に追加すると、レポーターは現在のページに、前に続く小節を作成します。既定では、タイトルのサイズがレポート階層のセクションの深さ (最大 5 レベル) に応じて小さくなります。5 よりも下層のセクションのタイトルには番号が付けられず、レベル 5 と同じフォント サイズになります。
section = Section(title)
は、指定されたタイトル テキストのセクション タイトルを含むレポート セクションを作成します。既定では、階層セクション番号がタイトル テキストの前に付けられます。たとえば、2 番目の章で最初の節に付く既定の番号は 2.1 です。既定では、タイトルのフォント サイズがレポート階層のセクションの深さ (最大 5 レベル) に応じて小さくなります。
は、名前と値のペアを使用してプロパティを設定します。複数の名前と値のペアの引数を任意の順番で指定できます。section
= Section(Name=Value
)
プロパティ
メソッド
例
レポート セクションへのコンテンツの追加
章に節を追加し、レポートに章を追加します。章のレイアウト方向を横向きに設定します。
import mlreportgen.report.* import mlreportgen.dom.* theReport = Report("SectionExampleReport","pdf"); append(theReport,TitlePage(Title="Report with Sections")); append(theReport,TableOfContents); theChapter = Chapter("Images"); append(theChapter,Section(Title="Boeing 747",Content=Image("BoeingSectionExample.jpg"))); append(theChapter,Section(Title="Peppers",Content=Image("PeppersSectionExample.png"))); append(theReport,theChapter); close(theReport); rptview(theReport);
生成されたレポートのイメージを含むセクションは次のようになります。
セクション タイトルとしての DOM Text オブジェクトの使用
この例では、DOM Text
オブジェクトを使用してタイトルを定義します。DOM オブジェクトを使用することで、そのプロパティを設定し、セクション タイトルの既定色である黒をオーバーライドできます。
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)
セクションの配置の変更
この例では、節のタイトルを中央揃えに設定するレポートを生成します。
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);
バージョン履歴
R2017b で導入