Filter löschen
Filter löschen

Make first column of table bold

8 Ansichten (letzte 30 Tage)
Jack Arnoldi
Jack Arnoldi am 1 Jul. 2019
Bearbeitet: Jack Arnoldi am 1 Jul. 2019
I have a table created with the class
FormalTable
and I want to make the text in the first column bold but I can't find the property. In the documentation there is no property about it.
Can anyone give me a way to do what I want?
I am trying with
grps(1) = TableColSpecGroup;
specs(1) = TableColSpec;
specs(1).Style = {fontweight('Bold')}; % this creates an error
grps(1).ColSpecs = specs;
tableFAIL.ColSpecGroups = grps;
But this doesn't work because I still can't find the property for putting the text Bold
Thank you in advance!

Akzeptierte Antwort

Rahul Singhal
Rahul Singhal am 1 Jul. 2019
Bearbeitet: Rahul Singhal am 1 Jul. 2019
Hi Jack,
You can use the ColSpecGroups property of the FormalTable to format one or more columns in the table. Use the Bold format to make the content bold.
Example,
import mlreportgen.dom.*
d = Document('mydoc','docx');
% Define column specs to format one or more table columns
grps(1) = TableColSpecGroup;
specs(1) = TableColSpec;
specs(1).Style = {Bold()};
grps(1).ColSpecs = specs;
% Create the table and assign the column specs
table = FormalTable(magic(5));
table.ColSpecGroups = grps;
append(d,table);
% Close and view the report
close(d);
rptview(d);
Thanks,
Rahul
  1 Kommentar
Jack Arnoldi
Jack Arnoldi am 1 Jul. 2019
Bearbeitet: Jack Arnoldi am 1 Jul. 2019
Hi Rahul, thank you for your answer.
Your solution doesn't work for me... Here is my code
tableFAIL = FormalTable((tempsliced(s)));
tableFAIL.ColSep = 'single';
tableFAIL.RowSep = 'single';
tableFAIL.HAlign = 'center';
tableFAIL.Width = '100%';
grps(1) = TableColSpecGroup;
specs(1) = TableColSpec;
specs(1).Style = {Bold()}; %Also tried with Bold(1)
grps(1).ColSpecs = specs;
tableFAIL.ColSpecGroups = grps;
add(SectionFAIL, tableFAIL);
I don't really know where the problem comes from as I don't receive any error message..

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Report Generator Task Examples finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by