Main Content

replace

Class: mlreportgen.ppt.TablePlaceholder
Namespace: mlreportgen.ppt

Replace table placeholder with table

Description

replacementTableObj = replace(tablePlaceholder,table) replaces the specified table placeholder with the specified table and returns the table object.

example

Examples

expand all

Add a Title and Table slide to a presentation and then replace the title and table placeholders with your own title and table.

Import the PPT namespace so that you do not have to use long, fully qualified names for the PPT API classes.

import mlreportgen.ppt.*

Create a presentation.

ppt = Presentation("myTablePlaceholderPresentation.pptx");
open(ppt);

Add a slide that has a Title and Table layout.

slide = add(ppt,"Title and Table");

Use the find method of the slide object to find the placeholder object that has the name Title.

titlePlaceholderObj = find(slide,"Title")
titlePlaceholderObj = 
  TextBoxPlaceholder with properties:

                 Bold: []
                 Font: []
    ComplexScriptFont: []
            FontColor: []
             FontSize: []
               Italic: []
               Strike: []
            Subscript: []
          Superscript: []
            Underline: []
      BackgroundColor: []
               VAlign: []
                 Name: 'Title'
                    X: []
                    Y: []
                Width: []
               Height: []
                Style: []
             Children: []
               Parent: [1×1 mlreportgen.ppt.Slide]
                  Tag: 'ppt.TextBoxPlaceholder:555:529'
                   Id: '555:529'

The find method returns an mlreportgen.ppt.TextBoxPlaceholder object.

Replace the placeholder content with the title text.

replace(titlePlaceholderObj,"Fourth-Order Magic Square");

Use the find method of the slide object to find the placeholder object that has the name Table.

tablePlaceholderObj = find(slide,"Table")
tablePlaceholderObj = 
  TablePlaceholder with properties:

                 Bold: []
                 Font: []
    ComplexScriptFont: []
            FontColor: []
             FontSize: []
               Italic: []
               Strike: []
            Subscript: []
          Superscript: []
            Underline: []
      BackgroundColor: []
               VAlign: []
                 Name: 'Table'
                    X: []
                    Y: []
                Width: []
               Height: []
                Style: []
             Children: []
               Parent: [1×1 mlreportgen.ppt.Slide]
                  Tag: 'ppt.TablePlaceholder:556:530'
                   Id: '556:530'

The find method returns an mlreportgen.ppt.TablePlaceholder object.

Replace the table placeholder with a table for a fourth-order magic square.

replace(tablePlaceholderObj,Table(magic(4)));

Close and view the presentation

close(ppt);
rptview(ppt);

Here is the slide in the generated presentation:

Input Arguments

expand all

Table placeholder, specified as an mlreportgen.ppt.TablePlaceholder object.

Table to use as the replacement for the table placeholder, specified as an mlreportgen.ppt.Table object.

Output Arguments

expand all

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

Version History

Introduced in R2015b