主要内容

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

mlreportgen.ppt.BackgroundColor 类

命名空间: mlreportgen.ppt

演示文稿元素的背景颜色

描述

指定这些演示文稿元素 PPT API 对象的背景颜色:

  • TextBox

  • TextBoxPlaceholder

  • ContentPlaceholder

  • TablePlaceholder

  • Table

  • TableRow

  • TableEntry

  • ColSpec

  • TextBox

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

创建对象

描述

backgroundColorObj = BackgroundColor 创建白色背景。

backgroundColorObj = BackgroundColor(color) 根据指定的 CSS 颜色名称或十六进制 RGB 颜色值创建背景颜色对象。

示例

输入参量

全部展开

背景颜色,指定为字符向量或字符串标量。您可以使用:

  • 颜色名称,指定为字符向量或字符串标量。该名称必须是 CSS 颜色名称。请参阅 https://www.w3.org/wiki/CSS/Properties/color/keywords

  • 十六进制 RGB(红、绿、蓝)颜色值,指定为字符向量或字符串标量。使用格式 #RRGGBB。使用 # 作为第一个字符,并使用两位十六进制数分别表示红色、绿色和蓝色的值。例如,"#0000ff" 指定蓝色。

属性

全部展开

颜色名称,指定为字符向量,使用以下值之一:

  • CSS 颜色名称。请参阅 https://www.w3.org/wiki/CSS/Properties/color/keywords

  • RGB 值,使用具有 #RRGGBB 格式的字符向量。使用 # 作为第一个字符,并使用两位十六进制数分别表示红色、绿色和蓝色的值。例如,"#0000ff" 指定蓝色。

属性:

GetAccess
public
SetAccess
public
NonCopyable
true

数据类型: char | string

标记,指定为字符向量或字符串标量。PPT API 在创建此对象的过程中生成一个会话唯一标记。生成的标记形式为 CLASS:ID,其中 CLASS 是对象类,ID 是对象的 Id 属性的值。使用此值来帮助确定在文档生成过程中出现的问题的位置。

属性:

GetAccess
public
SetAccess
public
NonCopyable
true

数据类型: char | string

目标标识符,指定为字符向量或字符串标量。PPT API 在创建文档元素对象时会生成一个会话唯一标识符。您可以为 Id 指定自己的值。

属性:

GetAccess
public
SetAccess
public
NonCopyable
true

数据类型: char | string

示例

全部折叠

创建一个包含不同颜色行和表条目的表。

创建一个带有 A Colorful Table 标题幻灯片的演示文稿。

import mlreportgen.ppt.*

ppt = Presentation("myBackground.pptx");
open(ppt);
slide1 = add(ppt,"Title and Content");
replace(slide1,"Title","A Colorful Table");

定义表,为顶行和第二行的第一个条目指定不同的颜色。

table1 = Table();

row1 = TableRow();
row1.Style = {BackgroundColor("beige")};
row1entry1 = TableEntry();
p2 = Paragraph("Beige row");
append(row1entry1,p2);
row1entry2 = TableEntry();
p3 = Paragraph("More text");
append(row1entry2,p3);
append(row1,row1entry1);
append(row1,row1entry2);

row2 = TableRow();
row2entry1 = TableEntry();
row2entry1.Style = {BackgroundColor("yellow")};
p4 = Paragraph("yellow cell");
append(row2entry1,p4);
row2entry2 = TableEntry();
p5 = Paragraph("default white background");
append(row2entry2,p5);
append(row2,row2entry1);
append(row2,row2entry2);

append(table1,row1);
append(table1,row2);

用表替换幻灯片内容,生成演示文稿,然后打开 myBackground 演示文稿。

replace(slide1,"Content",table1);
close(ppt); 
rptview(ppt);

Sample slide with the heading A Colorful Table. In the table, the table headers are beige, and the first body cell is highlighted in yellow, while the second cell has no background color.

版本历史记录

在 R2020a 中推出