Main Content

mlreportgen.ppt.BackgroundColor Class

Namespace: mlreportgen.ppt

Background color of presentation element

Since R2020a

Description

Specifies the background color of these presentation element PPT API objects:

  • TextBox

  • TextBoxPlaceholder

  • ContentPlaceholder

  • TablePlaceholder

  • Table

  • TableRow

  • TableEntry

  • ColSpec

  • TextBox

The mlreportgen.ppt.BackgroundColor class is a handle class.

Creation

Description

backgroundColorObj = BackgroundColor creates a white background.

example

backgroundColorObj = BackgroundColor(color) creates a background color object based on the specified CSS color name or hexadecimal RGB color value.

Input Arguments

expand all

Background color, specified as a character vector. You can use:

  • The name of a color, specified as a character vector. The name must be a CSS color name. See https://www.w3.org/wiki/CSS/Properties/color/keywords.

  • Hexadecimal RGB (red, green, blue) color value, specified as a character vector. Use the format #RRGGBB. Use # as the first character and two-digit hexadecimal numbers each for the red, green, and blue values. For example, '#0000ff' specifies blue.

Properties

expand all

ID for this PPT API object, specified as a character vector or string scalar. A session-unique ID is generated as part of the object creation. You can specify an ID to replace the generated ID.

Attributes:

NonCopyable
true

Data Types: char | string

Tag for this PPT API object, specified as a character vector or string scalar. A session-unique tag is generated as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object.

Specifying your own tag value can help you to identify where issues occur during presentation generation.

Attributes:

NonCopyable
true

Data Types: char | string

The name of a color, specified as a character vector, using one of these values:

  • A CSS color name. See https://www.w3.org/wiki/CSS/Properties/color/keywords.

  • An RGB value, using a character vector having the format #RRGGBB. Use # as the first character and two-digit hexadecimal numbers each for the red, green, and blue values. For example, '#0000ff' specifies blue.

Examples

collapse all

Create a table with different color rows and table entries.

Set up a presentation with a slide titled A Colorful Table.

import mlreportgen.ppt.*

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

Define the table, specifying different colors for the top row and for the first entry in the second row.

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);

Replace the slide content with the table, generate the presentation, and open the myBackground presentation.

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

Version History

Introduced in R2020a