Main Content

Presentation Formatting Approaches

With the MATLAB® API for PowerPoint® (PPT API), you can use a PowerPoint template and PPT API format objects and properties to specify the appearance of an object. The PPT API supports four approaches for formatting elements of a presentation.

Formatting ApproachUse

Define formatting in the PowerPoint template.

  • Applying formatting globally within a presentation

  • Maintaining consistency across presentations

  • Extending formatting options that the PPT API provides

Using the PPT API, specify format objects to define a style for a presentation object.

  • Formatting a specific presentation element

  • Specifying multiple format options in one statement

  • Specifying complicated values such as hexadecimal color values that are used repeatedly in a program

  • Extending formatting options beyond the ones that format properties of an object provide

  • Defining a style to use with multiple objects

Using the PPT API, set format properties of a presentation object.

  • Specifying one or two basic format options for a specific presentation object

  • Extending formatting options beyond those options that format properties of an object provide

  • Specifying one or two basic format options for a specific presentation object

In the PowerPoint software, format a generated PPT API.

  • Customizing a specific version of a generated presentation

  • Extending formatting options beyond those options that the format objects provide

Template Formatting

Use templates for applying formatting globally:

  • Across a whole presentation, for example, the background color of slides.

  • To specific kinds of elements in a presentation, for example, slide titles.

Using a PowerPoint template with the PPT API involves creating and formatting template elements such as:

  • Slide masters

  • Slide layouts

  • Placeholders

  • Table styles

Using the template to define formatting offers more formatting options than the PPT API provides. Defining formatting in the template allows you to have consistent formatting in any PPT API presentation that used the template.

To format specific content in a specific slide, consider using one of the other approaches. Adding special-case formatting elements in a template can make the template overly complex.

Format Objects

You can define PPT API format objects and use them to specify a formatting style for presentation objects. After you create a presentation object, you can define the Style property for that object, using a cell array of format objects. For example:

import mlreporgen.ppt.*

p = Paragraph('Model Highlights');
p.Style = {FontColor('red'),Bold(true)};

It is a best practice to set the Style property by concatenating the existing value of the Style property and the cell array of format objects that you are adding. For example:

import mlreporgen.ppt.*

p = Paragraph('Model Highlights');
p.Style = [p.Style {FontColor('red'),Bold(true)}];

This practice prevents inadvertent removal of format objects that you previously added or that the PPT API added to synchronize the Style property with the format properties.

For many presentation objects, using format objects provides more formatting options than the format properties of the presentation objects. Using format objects can streamline your code: you can combine multiple formatting options in one statement and apply a defined style to multiple presentation objects.

Format Properties

Use format properties of a PPT API presentation element for basic formatting of a specific presentation object.

After you define a presentation object, you can set values for its format properties. For example:

import mlreportgen.ppt.*

p = Paragraph('My paragraph');
p.FontColor = 'red';
p.Font = 'Arial';
p.FontSize = '18pt';

The formatting applies only to the specific object. If you want to set just one option for a presentation element, using a format property is the simplest approach.

Interactive Formatting of Slide Content

After you generate a PPT API presentation, you can use the PowerPoint software to fine-tune the formatting.

In PowerPoint, you can use all PowerPoint formatting options, including options that you cannot specify with the PPT API, such as animation. Interactive editing of slide content of the generated presentation allows you to customize a specific version of the presentation without impacting future versions of the presentation.

If you use PowerPoint to customize a presentation generated using the PPT API, you lose those customizations when you generate the presentation again. To preserve the interactive formatting of content, save the customized version of the presentation using a different file name.

Related Examples

More About