主要内容

本页采用了机器翻译。点击此处可查看英文原文。

replace

类: mlreportgen.ppt.TablePlaceholder
命名空间: mlreportgen.ppt

用表替换表占位符

说明

replacementTableObj = replace(tablePlaceholder,table) 用指定的表替换指定的表占位符并返回表对象。

示例

示例

全部展开

在演示文稿中添加 Title and Table 幻灯片,然后用您自己的标题和表替换标题和表占位符。

导入 PPT 命名空间,这样您就不必对 PPT API 类使用长而完全限定的名称。

import mlreportgen.ppt.*

创建演示文稿。

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

添加具有 Title and Table 布局的幻灯片。

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

使用幻灯片对象的 find 方法查找名为 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'

find 方法返回一个 mlreportgen.ppt.TextBoxPlaceholder 对象。

用标题文本替换占位符内容。

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

使用幻灯片对象的 find 方法查找名为 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'

find 方法返回一个 mlreportgen.ppt.TablePlaceholder 对象。

将表格占位符替换为四阶幻方表。

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

关闭并查看演示文稿

close(ppt);
rptview(ppt);

以下是生成的演示文稿中的幻灯片:

输入参数

全部展开

表占位符,指定为 mlreportgen.ppt.TablePlaceholder 对象。

用于替换表占位符的表,指定为 mlreportgen.ppt.Table 对象。

输出参量

全部展开

替换表,作为 mlreportgen.ppt.Table 对象返回。

版本历史记录

在 R2015b 中推出