Main Content

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

mlreportgen.ppt.PicturePlaceholder 类

命名空间: mlreportgen.ppt

幻灯片图片的占位符

描述

mlreportgen.ppt.PicturePlaceholder 类的对象表示幻灯片中的图片占位符。

当您向演示文稿中添加幻灯片以及具有图片占位符的幻灯片布局时,PPT API 会创建一个 PicturePlaceholder 对象。在默认的 PPT API 中,Title and PicturePicture with Caption 布局有图片占位符。

要查找 PicturePlaceholder 对象,请使用包含图片占位符的幻灯片的 find 方法。要用图片替换图片占位符,请使用 PicturePlaceholder 对象的 replace 方法。replace 方法用 mlreportgen.ppt.Picture 对象替换 PicturePlaceholder 对象。

注意

Microsoft® PowerPoint® 调整图片大小以适合图片占位符。当您希望幻灯片中的占位符位置和大小固定时,请使用带有图片占位符的幻灯片。您可以通过修改 PowerPoint 中的幻灯片布局来指定图片占位符的位置和大小。请参阅设置 PowerPoint 演示模板。如果占位符的位置和大小不必固定,则可以使用布局中具有内容占位符的幻灯片。PowerPoint 会调整内容占位符的大小以适应图片的大小。请参阅 mlreportgen.ppt.ContentPlaceholder

mlreportgen.ppt.PicturePlaceholder 类是一个 handle 类。

类属性

HandleCompatible
true
ConstructOnLoad
true

有关类属性的信息,请参阅类属性

属性

全部展开

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

图片占位符名称,指定为字符向量或字符串标量。

左上角 x 坐标位置,指定为字符向量或字符串标量,由数字和后跟测量单位缩写组成。例如,“5in”表示五英寸。有效的缩写是:

  • "px" - 像素

  • "cm" - 厘米

  • "in" - 英寸

  • "mm" - 毫米

  • "pc" - 派卡

  • "pt" - 磅

属性:

NonCopyable
true

数据类型: char | string

左上角 y 坐标位置,指定为字符向量或字符串标量,由数字和后跟测量单位缩写组成。例如,“5in”表示五英寸。有效的缩写是:

  • "px" - 像素

  • "cm" - 厘米

  • "in" - 英寸

  • "mm" - 毫米

  • "pc" - 派卡

  • "pt" - 磅

属性:

NonCopyable
true

数据类型: char | string

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

该类忽略此属性。

属性:

NonCopyable
true

此 PPT API 对象的子元素,指定为 PPT API 对象的元胞数组。

属性:

NonCopyable
true

该对象的父级,指定为 PPT 对象。

属性:

SetAccess
private
NonCopyable
true

此 PPT API 对象的 ID,指定为字符向量或字符串标量。会话唯一 ID 是在对象创建过程中生成的。您可以指定一个 ID 来 替换生成的 ID。

属性:

NonCopyable
true

数据类型: char | string

此 PPT API 对象的标签,指定为字符向量或字符串标量。在创建此对象的过程中会生成一个会话唯一标签。生成的标签形式为 CLASS:ID,其中 CLASS 是对象类,ID 是对象的 Id 属性的值。

指定您自己的标签值可以帮助您识别演示文稿生成过程中出现问题的位置。

属性:

NonCopyable
true

数据类型: char | string

方法

全部展开

示例

全部折叠

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

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

import mlreportgen.ppt.*

创建演示文稿。

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

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

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

使用幻灯片对象的 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:30:125'
                   Id: '30:125'

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

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

replace(titlePlaceholderObj,"Airplane");

使用幻灯片对象的 find 方法查找名为 Picture 的占位符对象。

picturePlaceholderObj = find(slide,"Picture")
picturePlaceholderObj = 
  PicturePlaceholder with properties:

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

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

用图片替换图片占位符。

replace(picturePlaceholderObj,Picture("b747.jpg"));

关闭并查看演示文稿。

close(ppt);
rptview(ppt);

PowerPoint® 调整图片尺寸以适合图片占位符。如果图片占位符尺寸大于 Picture 对象尺寸,则图片会按比例拉伸。如果尺寸较小,则图片位于中央。

提示

  • 当您用图片替换演示文稿中的图片占位符,然后将该演示文稿用作新演示文稿的模板时,PPT API 会为新演示文稿中的图片创建一个 mlreportgen.ppt.TemplatePicture 对象。请参阅添加或替换图片

  • 要查看 PPT API 为幻灯片对象创建的占位符对象,请查看幻灯片的 Children 属性。例如,当您向演示文稿添加 Title and Picture 幻灯片时,Children 属性是一个包含 mlreportgen.ppt.TextBoxPlaceholder 对象和 mlreportgen.ppt.PicturePlaceholder 对象的数组。

    ppt = mlreportgen.ppt.Presentation("test.pptx");
    open(ppt);
    slide = add(ppt,"Title and Picture");
    slide.Children(1)
    
    ans = 
    
      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:6:9'
                       Id: '6:9'

    slide.Children(2)
    
    ans = 
    
      PicturePlaceholder with properties:
    
                     Bold: []
                     Font: []
        ComplexScriptFont: []
                FontColor: []
                 FontSize: []
                   Italic: []
                   Strike: []
                Subscript: []
              Superscript: []
                Underline: []
          BackgroundColor: []
                   VAlign: []
                     Name: 'Picture'
                        X: []
                        Y: []
                    Width: []
                   Height: []
                    Style: []
                 Children: []
                   Parent: [1×1 mlreportgen.ppt.Slide]
                      Tag: 'ppt.PicturePlaceholder:7:10'
                       Id: '7:10'

版本历史记录

在 R2015b 中推出