Create PPT Objects
PPT Objects
The PPT API consists of a hierarchical set of data structures, known as objects, that represent a presentation and its contents. The top of the hierarchy has an object representing the presentation. The PPT API maintains a list of objects, called the presentation children, that represent the presentation contents (slides, paragraphs, tables, pictures, etc.). Each child object, in turn, maintains a list of its contents. For example, the children of a table object are its row objects, the children of a row object are its entry objects, and so on.
The PPT API contains functions (also known as methods) to create and assemble PPT objects, such as paragraphs and tables, and add the objects to slides.
The PPT API includes format objects, such as bold and font color objects, that you can use to define formatting for presentation elements.
To generate a PowerPoint® presentation file, use the PPT API. You can open, view, and edit the generated presentation as you do with any other PowerPoint presentation.
Use a PPT Constructor
The PPT API includes a set of MATLAB® functions, called constructors, that you use to create PPT objects of various types.
The name of an object constructor is the name of the MATLAB class from which the PPT API creates an object. For example, the name of the constructor for a PPT paragraph object is mlreportgen.ppt.Paragraph
. Some constructors do not require any arguments. Other constructors can take arguments that typically specify its initial content and properties. For example, this code creates a paragraph object, p
, whose initial content is Slide 1
.
p = mlreportgen.ppt.Paragraph('Slide 1');
A constructor returns a handle to the object it creates. Assigning the handle to a variable allows you to append content to the object or set its properties. For example, this code appends content to the paragraph object p
.
append(p,'-- In the Beginning');
PPT Objects Created Without Constructors
You can use some PPT API functions to create PPT objects without including a constructor in your code. For example, to create a slide, add a slide layout to a presentation without an mlreportgen.ppt.Slide
constructor. This code uses an add
method for the mlreportgen.ppt.Presentation
object slides
. The add
method creates a Slide
object named slide1
based on the Title Slide
layout in the default PPT API PowerPoint template.
import mlreportgen.ppt.*; ppt = Presentation('MySlides'); slide1 = add(ppt,'Title Slide')
slide1 = Slide with properties: Layout: 'Title Slide' SlideMaster: 'Office Theme' Name: '' Style: [] Children: [1x2 mlreportgen.ppt.TextBoxPlaceholder] Parent: [1x1 mlreportgen.ppt.Presentation] Tag: 'ppt.Slide:16' Id: '16'