Main Content

章の作成

mlreportgen.report.Chapter クラスを使用してレポートに章を追加できます。DOM オブジェクトを使用して章を作成するよりも、このクラスを使用する方がはるかに簡単で効率的です。Chapter クラスは mlreportgen.report.Section から継承します。Chapter クラスは書式設定された章を自動的にレポートに追加します。既定の書式設定は縦方向で、ヘッダーとフッターがあります。フッターにはページ番号が含まれます。章のレイアウトはオーバーライドできます。

詳細と例については、mlreportgen.report.Chapter を参照してください。

この例では、タイトル ページを作成し、ページの方向を横方向に設定するコードを示します。

次のコマンドを実行して、この例で使用されているサポート ファイルにアクセスします。

openExample('rptgen/MatlabReportGeneratorSupportFilesExample');
import mlreportgen.report.*
import mlreportgen.dom.*

rpt = Report('My Report','pdf');

add(rpt,TitlePage('Title','My Report'));

chapter = Chapter('Images');
chapter.Layout.Landscape = true;
add(chapter,Section('Title','Boeing 747', ...
     'Content',Image(which('b747.jpg'))));

add(rpt,chapter);
close(rpt);
rptview(rpt);

Chapter one with a picture of a Boeing 747