replace

Class: mlreportgen.ppt.TemplateTable
Package: mlreportgen.ppt

Replace template table with another table

Syntax

newTable = replace(templateTable,replacementTable)

Description

newTable = replace(templateTable,replacementTable) replaces a template table with another table.

Input Arguments

expand all

Template table to replace, specified as an mlreportgen.ppt.TemplateTable object.

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

Output Arguments

expand all

New table in the presentation slide, specified as an mlreportgen.ppt.Table object.

Examples

expand all

Generate a presentation, MyTablePresentation, that you then use as the template presentation for another presentation. MyTablePresentation has one slide with one table

import mlreportgen.ppt.*
ppt = Presentation("MyTablePresentation");
open(ppt);
slide1 = add(ppt,"Title and Table");
replace(slide1,"Title","Magic Square Slide 1");
replace(slide1,"Table",Table(magic(3)));

Close and view the presentation.

close(ppt);
rptview(ppt);

Create a presentation, MyNewTablePresentation, from MyTablePresentation. MyTablePresentation is the template presentation for MyNewTablePresentation,

ppt = Presentation("MyNewTablePresentation","MyTablePresentation");
open(ppt);

Find the template table by using the find method of the slide object. Because the table comes from a template presentation slide, find returns the table as an mlreportgen.ppt.TemplateTable object.

slide1 = ppt.Children(1);
templateTableObj1 = find(slide1,"Table")
templateTableObj1 = 
  TemplateTable with properties:

    XMLMarkup: '<p:graphicFrame><p:nvGraphicFramePr><p:cNvPr id="3" name="Table"/><p:cNvGraphicFramePr><a:graphicFrameLocks noGrp="1"/></p:cNvGraphicFramePr><p:nvPr><p:ph idx="1" type="tbl"/></p:nvPr></p:nvGraphicFramePr><p:xfrm><a:off x="838200" y="1825625"/><a:ext cx="10515600" cy="4351338"/></p:xfrm><a:graphic><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/table"><a:tbl><a:tblPr bandRow="1" firstRow="1"/><a:tblGrid><a:gridCol w="3505200"/><a:gridCol w="3505200"/><a:gridCol w="3505200"/></a:tblGrid><a:tr h="0"><a:tc><a:txBody><a:bodyPr/><a:p><a:r><a:t>8</a:t></a:r></a:p></a:txBody></a:tc><a:tc><a:txBody><a:bodyPr/><a:p><a:r><a:t>1</a:t></a:r></a:p></a:txBody></a:tc><a:tc><a:txBody><a:bodyPr/><a:p><a:r><a:t>6</a:t></a:r></a:p></a:txBody></a:tc></a:tr><a:tr h="0"><a:tc><a:txBody><a:bodyPr/><a:p><a:r><a:t>3</a:t></a:r></a:p></a:txBody></a:tc><a:tc><a:txBody><a:bodyPr/><a:p><a:r><a:t>5</a:t></a:r></a:p></a:txBody></a:tc><a:tc><a:txBody><a:bodyPr/><a:p><a:r><a:t>7</a:t></a:r></a:p></a:txBody></a:tc></a:tr><a:tr h="0"><a:tc><a:txBody><a:bodyPr/><a:p><a:r><a:t>4</a:t></a:r></a:p></a:txBody></a:tc><a:tc><a:txBody><a:bodyPr/><a:p><a:r><a:t>9</a:t></a:r></a:p></a:txBody></a:tc><a:tc><a:txBody><a:bodyPr/><a:p><a:r><a:t>2</a:t></a:r></a:p></a:txBody></a:tc></a:tr></a:tbl></a:graphicData></a:graphic></p:graphicFrame>'
         Name: 'Table'
            X: '838200emu'
            Y: '1825625emu'
        Width: '10515600emu'
       Height: '4351338emu'
        Style: []
     Children: []
       Parent: [1×1 mlreportgen.ppt.Slide]
          Tag: 'ppt.TemplateTable:883:428'
           Id: '883:428'

Replace the table on the slide with a table for a 4-by-4 magic square.

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

Close and view the presentation.

close(ppt);
rptview(ppt);

Introduced in R2019b