Main Content

Presentation Format Inheritance

The PPT API allows you to use a PowerPoint® template and PPT API format objects and properties to format presentation objects. You can combine formatting approaches.

The formatting you specify in a PowerPoint template specifies the default format of presentation content.

You can use a PPT API to format a specific presentation object. You can:

  • Define format objects that you can use with a presentation object Style property.

  • Specify a value for a format property of a presentation object.

You can combine formatting with the Style property and formatting with format properties. For example:

p = Paragraph('This is a paragraph');
p.Style = {Bold(true),Underline('wavy')};
p.FontColor = 'red';

If you define the same formatting characteristic using each approach, the PPT API uses the specification that appears later in the code. For example, this code specifies blue as the default color for text in a paragraph:

p = Paragraph('This is a paragraph');
p.Style = {FontColor('red')};
p.FontColor = 'blue';

Several PPT API objects are hierarchical. For example:

  • You can append a Text object to a Paragraph object.

  • You append TableEntry objects to a TableRow object, and you can append TableRow objects to a Table object.

The formatting for a parent object applies to its child objects. However, formats specified by the child object override the parent formatting. For example:

import mlreportgen.ppt.*;

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

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

%% Use Unicode for special characters
p = Paragraph('Parent default red text: ');
p.FontColor = 'red';

t = Text('child text object blue text');
t.FontColor = 'blue';

append(p,t);
add(slide1,'Content',p);

close(ppt);
rptview(ppt);

Bulleted list item with a red bullet and red text "Parent default red text, followed by blue text "child text object blue text"