mlreportgen.dom.ResizeToFitContents class

Package: mlreportgen.dom
Superclasses:

Allow table to resize its columns

Description

Specifies whether a table resizes its columns to fit content.

Construction

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.

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

Output Arguments

expand all

Specification of whether a table resizes its columns to fit content or wraps content, represented by an mlreportgen.dom.ResizeToFitContents object.

Properties

expand all

ID for this document element, specified as a character vector. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

Tag for the document element, specified as a character vector.

The DOM generates a session-unique tag when it creates the document element. Structure the tag as class:id, where class is the class of the element and id is the value of the Id property. You can specify a tag to replace the generated tag. Specifying your own tag can make it easier to identify where an issue occurred during document generation.

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(ones(4,4));
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(ones(4, 4));
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);