User`s guide

Create Microsoft Word Page Layout Sections
13-129
rpt = Document('test','docx');
open(rpt);
sect = rpt.CurrentDOCXSection;
pageSize = sect.PageSize;
pageSize.Orientation = 'landscape';
saveHeight = pageSize.Height;
pageSize.Height = pageSize.Width;
pageSize.Width = saveHeight;
table = append(rpt,magic(22));
table.Border = 'solid';
table.ColSep = 'solid';
table.RowSep = 'solid';
close(rpt);
rptview(rpt.OutputPath);
Create Sections Programmatically
You can use the append function of a Document or DocumentPart to create sections
programmatically. To use the append function to add a section to a report, use this
append syntax:
paraObj = append(rptObj,paraObj,docxSectionObj)
This us of the append function appends a paragraph to the report as the last paragraph
of the current section and then starts a new section whose properties are defined by a
DOCXSection object. For example, this script adds a landscape section to a report to
accommodate a large magic square.
import mlreportgen.dom.*
rpt = Document('test','docx');
append(rpt,Heading(1,'Magic Square Report','Heading 1'));
sect = DOCXSection;
sect.PageSize.Orientation = 'landscape';
sect.PageSize.Height = '8.5in';
sect.PageSize.Width = '11in';
append(rpt,Paragraph('The next page shows magic square.'),sect);