Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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 document element, specified as a character vector.

A session-unique ID is generated as part of document element creation. The generated tag has the form CLASS:ID, where CLASS is the class of the element and ID is the value of the Id property of the object. You can specify a tag to replace the generated tag.

For example, to make it easier to identify where an issue occurred during document generation, you can specify your own tag value.

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

expand 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);
Was this topic helpful?