mlreportgen.ppt.Table class

Package: mlreportgen.ppt
Superclasses:

Description

Table to include in a presentation.

Create a table using one of these approaches:

  • Create an empty table and append table rows, with table entries for each column.

  • Create a table, using an array or cell array to specify the table content.

After you create a table, you can add rows to it, and add entries to each table row. The row with the largest number of table entries determines the number of columns in the table if there are more table entries in the row than the number of rows specified in the mlreportgen.ppt.Table object constructor.

Construction

tableObj = mlreportgen.ppt.Table() creates an empty table object.

tableObj = mlreportgen.ppt.Table(nCols) creates an empty table object with the number of columns you specify.

tableObj = mlreportgen.ppt.Table(tableValues) returns a table whose content is specified by a two-dimensional numeric array or a two-dimensional cell array of numbers, character vectors, or mlreportgen.ppt.Paragraph objects.

Input Arguments

expand all

Number of table columns, specified as a double.

Data Types: double

Table values, specified as one of these values:

  • Two-dimensional numeric array

  • Two-dimensional cell array of character vectors, numbers, categorical data, or mlreportgen.ppt.Paragraph objects, or a combination of these kinds of values

Output Arguments

expand all

Table, returned as an mlreportgen.ppt.Table object.

Properties

expand all

Number of table columns, specified as a double.

Data Types: double

Table name, specified as a character vector.

Array of mlreportgen.ppt.ColSpec objects that specify the width, alignment, and other formatting properties of the table columns. The first object applies to the first column, the second object applies to the second column, and so on.

Table style name from the template for the presentation, specified as a character vector.

Upper left x-coordinate position of table, specified in the form valueUnits where Units is an abbreviation for the x-position units. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Upper left y-coordinate position of table, specified in the form valueUnits where Units is an abbreviation for the y-position units. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Width of table, specified in the form valueUnits where Units is an abbreviation for the units for the width. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Height of table, specified in the form valueUnits where Units is an abbreviation for the units for the height. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Specifying a table height causes the table rows to have equally spaced heights whose sum is the specified table height. If the contents of a row do not fit in its row height, that row height expands. This increased row height might cause the table to exceed its specified table height when the table is rendered.

Table formatting. This property is ignored.

Child elements of this object, specified as a cell array of PPT objects. This property is read-only.

Parent of this object, specified as a PPT object. This property is read-only.

ID for PPT API object, specified as a character vector. A session-unique ID is generated as part of object creation. You can specify an ID to replace the generated ID.

Tag for this PPT API object, specified as a character vector. A session-unique tag is generated 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.

Specifying your own tag value can help you to identify where an issue occurred during presentation generation.

Methods

Method

Purpose

append

Add content to table

replace

Replace table

row

Access table row

entry

Access table entry

Examples

collapse all

Create a presentation.

import mlreportgen.ppt.*

slidesFile = 'myTablePresentation.pptx';
slides = Presentation(slidesFile);

slide1 = add(slides,'Title and Table');
slide2 = add(slides,'Title and Table');

Create a table using a cell array.

table1 = Table({'a','b';'c','d'});
table1.Children(1).Style = {FontColor('red')};
table1.Children(2).Style = {FontColor('green')};

Use the mlreportgen.ppt.Presentation.find method to find the slides that have objects with a Name property set to Table. In the default PPT API, the Title and Table layout slide has a Table object.

contents = find(slides,'Table');

Replace the contents of the second slide with table1.

replace(contents(1),table1);

Create a second table using the MATLAB® magic function.

table2 = Table(magic(9));

Replace the table in the third slide with table2.

replace(contents(2),table2);

Close the presentation to generate the output.

close(slides);

Open myTablePresentation.pptx. On a Windows® platform, you can open the presentation in MATLAB.

if ispc
    winopen(slidesFile);
end

Introduced in R2015b