Make first row of Formal Table bold

16 次查看(过去 30 天)
Hello I have a Formal Table and I want the first row to be bold. I know you can make the first column bold with
grps(1) = TableColSpecGroup;
specs(1) = TableColSpec;
specs(1).Style = {Bold()};
grps(1).ColSpecs = specs;
mytab.ColSpecGroups = grps;
but I don't know how to the same thing with the rows... Can someone help me with this?
Thank you in advance!

采纳的回答

Rahul Singhal
Rahul Singhal 2019-7-25
Hi Jack,
I think you want the header row of the FormalTable to be bold.
Below example demostrates how to style the header first row as well as the first row of the table body.
import mlreportgen.dom.*
% Create a document
d = Document('output', 'pdf');
open(d);
% Create a FormalTable with one header row and two body rows
t = FormalTable({'Col1', 'Col2'}, {'entry11', 'entry12'; 'entry21', 'entry22'});
t.Border = 'solid';
t.RowSep = 'solid';
t.ColSep = 'solid';
t.Width = '4in';
% Specify styles for the header first row
headerRow = t.Header.Children(1);
headerRow.Style = [headerRow.Style {Bold()}];
% Specify styles for the first row of table body
bodyFirstRow = t.Body.Children(1);
bodyFirstRow.Style = [bodyFirstRow.Style {Color('red')}];
% Append table to the document
append(d,t);
% Close and view report
close(d);
rptview(d);
Hope this helps!
Thanks,
Rahul

更多回答(0 个)

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by