The Style property of TableCopSpec can be used to apply any format to one or more adjacent table columns. The below script will make the text to be left aligned in the first column, centered in the second column, and right aligned in the third column.
import mlreportgen.dom.*
rpt = Document('MyReport','pdf');
table = FormalTable(magic(3));
table.Width = '3in';
table.Border = 'solid';
table.ColSep = 'solid';
table.RowSep = 'solid';
groups(1) = TableColSpecGroup();
specs(1) = TableColSpec();
specs(1).Style = { HAlign('left') };
specs(2) = TableColSpec();
specs(2).Style = { HAlign('center') };
specs(3) = TableColSpec();
specs(3).Style = { HAlign('right') };
groups(1).ColSpecs = specs;
table.ColSpecGroups = groups;
append(rpt, table);
close(rpt);
rptview(rpt.OutputPath);
Best Answer