Documentation

mlreportgen.ppt.Presentation class

Package:mlreportgen.ppt

CreateMicrosoft PowerPointpresentation

Description

Creates aMicrosoft®PowerPoint®演示。

Construction

presentationObj= Presentation()创建一个表示命名Untitled.pptxin the current folder, using the default PPT APIdefault.pptxtemplate.

presentationObj= Presentation(presentationPath)creates a presentation at the specified location.

presentationObj= Presentation(presentationPath,templatePath)creates a presentation using the PowerPoint template at the specified location.

Input Arguments

expand all

presentationPath— Path to presentation filestring

Path to the presentation file, specified as a string.

templatePath— Path to PowerPoint template for presentationstring

Path to the PowerPoint template for the presentation, specified as a string.

Output Arguments

expand all

presentationObj— Presentationmlreportgen.ppt.Presentationobject

Presentation object, returned as anmlreportgen.ppt.Presentationobject

Properties

expand all

TemplatePathPath of the template used for this presentationstring

The path to the PowerPoint template to use for this presentation element, specified as a string.

OutputPathPath of output file or folder for this presentationstring

You set this property only before you open the presentation.

Path of this output file of the presentation, specified as a string.

ChildrenChildren of this PPT API objectcell array ofmlreportgen.ppt.Elementobjects

This read-only property lists child elements that the object contains, specified as a cell array.

IdID for PPT API objectstring

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

TagTag for this PPT API objectsession-unique tag generated as part of object creation (default) | string

Tag for this PPT API object, specified as a string. The generated tag has the formCLASS:ID, whereCLASSis the object class andIDis the value of theIdproperty of the object.

An example of a reason for specifying your own tag value is to make it easier to identify where an issue occurred during presentation generation.

Methods

Method

Purpose

open

Open presentation.

close

Close presentation.

find

Search in presentation.

Use thePresentation.findmethod the same way you use theSlide.findmethod.

replace

Replace content in presentation.

add

Add content to presentation.

getMasterNames

Get names of slide masters for presentation

getLayoutNames

Get names of layouts for presentation.

getTableStyleNames

Get table style names for presentation.

Examples

expand all

Create Presentation Using Default Template

Create a presentation with three slides. Use the default PPT presentation template.

importmlreportgen.ppt.*slides = Presentation('myFirstPresentation'); add(slides,'Title Slide'); add(slides,的标题和内容); add(slides,'Title and Picture');

Examine the slidesPresentationobject.

slides
slides = Presentation with properties: TemplatePath: 'matlab/toolbox/shared/mlreportgen/ppt/resources/...' OutputPath: 'myFirstPresentation.pptx' Children: [1x3 mlreportgen.ppt.Slide] Parent: [] Tag: 'ppt.Presentation:1181' Id: '1181'

Examine the first slide.

slides.Children(1)
ans = Slidewithproperties:Layout:'Title Slide'SlideMaster:'Office Theme'Name:''Style: [] Children: [1x2 mlreportgen.ppt.TextBoxPlaceholder] Parent: [1x1 mlreportgen.ppt.Presentation] Tag:'ppt.Slide:1183'Id:'1183'

Specify a title for the presentation. Find theTitleplaceholder in the first slide and provide a title. Make the title red.

contents = find(slides,'Title'); replace(contents(1),'My First Presentation'); contents(1).FontColor ='red';

Add content to the second slide.

contents = find(slides,'Content'); replace(contents,{'Subject A','Subject B','Subject C'});

Close the presentation to generate the output.

close(slides);

OpenmyFirstPresentation.pptx. On a Windows®platform, you can open the presentation in MATLAB®:

ifispc winopen(slidesFile);end

Create Presentation Specifying a Template

Create a presentation with using themyFirstPresentationpresentation as the template (see the previous example).

importmlreportgen.ppt.*slides = Presentation('mySecondPresentation','myFirstPresentation');

Change the title toMy Second Presentation.

contents = find(slides,'Title'); replace(contents(1),'My Second Presentation');

Close the presentation to generate the output.

close(slides);

OpenmySecondPresentation.pptx. On a Windows platform, you can open the presentation in MATLAB:

ifispc winopen(slidesFile);end

Related Examples

Introduced in R2015b

Was this topic helpful?