Main Content

mlreportgen.dom.ResizeToFitContents Class

Namespace: mlreportgen.dom

Allow table to resize its columns

Description

Specifies whether a table resizes its columns to fit content.

The mlreportgen.dom.ResizeToFitContents class is a handle class.

Creation

Description

resizeToFitContentsObj = ResizeToFitContents allows a table to resize its columns to fit their contents.

resizeToFitContentsObj = ResizeToFitContents(tf) allows a table to resize its columns to fit their contents, if tf is true.

example

Input Arguments

expand all

A setting of true (or 1) allows a table to resize its columns to fit their contents. A setting of false (or 0) causes the content to wrap.

Data Types: logical

Properties

expand all

Object identifier for the mlreportgen.dom.ResizeToFitContents object, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object. You can specify your own value for Id.

Attributes:

NonCopyable
true

Data Types: char | string

Tag for the mlreportgen.dom.ResizeToFitContents object, specified as a character vector or string scalar. The DOM API generates a session-unique tag as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object. Specify your own tag value to help you identify where to look when an issue occurs during document generation.

Attributes:

NonCopyable
true

Data Types: char | string

A setting of true (or 1) allows a table to resize its columns to fit their contents. A setting of false (or 0) causes the content to wrap.

If you set this property to true and also have set a column width using mlreportgen.dom.Width, the resulting column width depends on the output format. For PDF output, the table uses the specified column width and ignores the ResizeToFitContents setting. For all other output formats, ResizeToFitContents overrides the column width settings.

Data Types: logical

Examples

collapse all

Create a table and specify to resize the column widths to fit the widest table entry in the column.

import mlreportgen.dom.*;
doctype = 'html';
d = Document('test',doctype);

append(d,Heading(1,'Table 1'));
table1 = Table(arrayfun(@(x) Text(), ones(4))); % Create a table with text entries
table1.entry(1,2).Children(1).Content = 'MathWorks';

table1.Style = {ResizeToFitContents(true),Width('1in'), ...
    Border('solid'),RowSep('solid'),ColSep('solid')};

append(d,table1);

Create a second table, but do not have the columns resize to fit content.

append(d,Heading(1,'Table 2'));
table2 = Table(arrayfun(@(x) Text(), ones(4))); % Create a table with text entries
table2.entry(1,2).Children(1).Content = 'MathWorks';

table2.Style = {ResizeToFitContents(false),Width('1in'), ...
    Border('solid'), RowSep('solid'),ColSep('solid')};

append(d,table2);

Run the report.

close(d);
rptview(d.OutputPath,doctype);

Version History

Introduced in R2014b