Report Generator: Error when defining table column width in percent (fo:table-cell)

3 views (last 30 days)
Hi, after updating from R2016a to R2017b I am getting this error message when trying to generate reports in Matlab.
[ERROR] AbstractBaseLayoutManager - Cannot find LM to handle given FO for LengthBase. (fo:table-cell).
It looks like the problem is caused by the definition of column width in percent. What is confusing me is that the code worked well before (see below an example). Does anyone know how to avoid this error and still be able to define columns in percent?
Thanks
T_overview = Table(overview_body,'Overview');
T_overview.Width = '100%';
% Set column width of all columns
ncols = T_overview.NCols;
grps(1) = TableColSpecGroup;
grps(1).Span = ncols;
grps(1).Style = {Width('0.5')};
% Set properties of column 1
specs(1) = TableColSpec;
specs(1).Span = 1;
specs(1).Style = {Width('31.25%'),HAlign('left')};
grps(1).ColSpecs = specs;
T_overview.ColSpecGroups = grps;
append(doc,T_overview);

Answers (1)

Rahul Singhal
Rahul Singhal on 14 Nov 2017
I am not able to reproduce this issue, but the possible reason can be that in R2017a, the default table layout for PDF output was changed from fixed to auto. See MATLAB Report Generator Release Notes - R2017a .
So, for your code snippet, to preserve the layout that the table had in R2016a, add the table format ResizeToFitContents(false) to the table style.
T_overview.Style = [T_overview.Style, {ResizeToFitContents(false)}];
Hope this helps!
  2 Comments
MS
MS on 15 Nov 2017
Thanks, but this did not solve the problem. I made the following observations:
  • the issue seems to appear only with FormalTable, when using Table, I am able to define column width in percent with the code below.
  • When using FormalTable, the code only works if cell width is defined in cm.
T_rank1 = FormalTable(ranked_head1,ranked_body1,'Positions');
% T_rank1 = Table([ranked_head1;ranked_body1],'Positions');
T_rank1.Width = '100%';
clearvars specs grps
% Set column width of all columns
ncols = T_rank1.NCols;
grps(1) = TableColSpecGroup;
grps(1).Span = ncols;
grps(1).Style = {Width('0.5cm')};
% Set properties of column 1
specs(1) = TableColSpec;
specs(1).Span = 1;
specs(1).Style = {Width('30%'),HAlign('left')};
% Set properties of column 2
specs(2) = TableColSpec;
specs(2).Span = 1;
specs(2).Style = {Width('15%')};
% Set properties of column 3
specs(3) = TableColSpec;
specs(3).Span = 1;
specs(3).Style = {Width('10%')};
% Set properties of column 4
specs(4) = TableColSpec;
specs(4).Span = 1;
specs(4).Style = specs(1).Style;
% Set properties of column 5
specs(5) = TableColSpec;
specs(5).Span = 1;
specs(5).Style = specs(2).Style;
grps(1).ColSpecs = specs;
T_rank1.ColSpecGroups = grps;
append(doc,T_rank1);
Rahul Singhal
Rahul Singhal on 20 Dec 2017
Thanks for the input. This issue occurs in R2017b with the following combination:
  • Using a FormalTable with a Header specified.
  • Using TableColSpecGroup or TableColSpec to specify column width in percentage.
A simple workaround is not to use TableColSpecGroup and TableColSpec to specify width in percentage. Instead use Body.TableEntriesStyle to specify the width for all the columns. To override any column width, specify the width of any table entry in that particular column. For example,
T_rank1 = FormalTable(ranked_head1,ranked_body1,'Positions');
T_rank1.Body.Style = {Width('100%')};
% Set column width of all columns
T_rank1.Body.TableEntriesStyle = {Width('0.5cm')};
% Set width of column 1
T_rank1.Body.entry(1,1).Style = {Width('30%')};
% Set properties of column 2
T_rank1.Body.entry(1,2).Style = {Width('15%')};
append(doc,T_rank1);
Hope this helps!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!