主要内容

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

find

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

在幻灯片中搜索内容

说明

searchResults = find(slide,objectName) 在幻灯片中搜索 Name 属性值与 objectName 匹配的幻灯片内容对象。

示例

示例

全部展开

使用 mlreportgen.ppt.Slide 方法在 find 对象中查找内容对象。

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

import mlreportgen.ppt.*

创建演示文稿。

ppt = Presentation('mySlideFindPresentation.pptx');
open(ppt);

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

slide = add(ppt,'Title and Content');

在幻灯片中搜索具有 Name 属性值 'Content' 的内容对象。

contents = find(slide,'Content')
contents = 
  ContentPlaceholder with properties:

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

find 返回一个包含 mlreportgen.ppt.ContentPlaceholder 对象的 1×1 数 组。指定占位符对象中的文本为粗体,并将文本添加到该对象。

contents(1).Bold = true;
add(contents(1),'This is bold text');

关闭并查看演示文稿。

close(ppt);
rptview(ppt);

以下是生成的演示文稿:

输入参数

全部展开

要搜索的幻灯片,指定为 mlreportgen.ppt.Slide 对象。

要搜索的 Name 属性值,指定为字符向量或字符串标量。

当您向演示文稿添加幻灯片时,add 方法会根据幻灯片布局设置幻灯片中内容对象的 Name 属性。请参阅 getLayoutNamesName 属性值包括:

  • "Title"

  • "Content"

  • "Table"

  • "Picture"

  • "Text"

  • "Vertical Text"

Name 属性也可以设置为自定义值。

版本历史记录

在 R2015b 中推出