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.

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

example

Input Arguments

expand all

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

  • The name of a color, specified as a character vector or string scalar. 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 or string scalar. 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

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.

Object identifier for the mlreportgen.ppt.BackgroundColor object, specified as a character vector or string scalar. The PPT API generates a session-unique identifier when it creates the document element object. You can specify your own value for Id.

Attributes:

NonCopyable
true

Data Types: char | string

Tag for the mlreportgen.ppt.BackgroundColor object, specified as a character vector or string scalar. The PPT API generates a session-unique tag 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. Specify your own tag value to help you identify where to look when an issue occurs during document generation.

Attributes:

NonCopyable
true

Data Types: char | string

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

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.

Version History

Introduced in R2020a