Adding bulleted list to PowerPoint using MATLAB Report Generator

9 visualizzazioni (ultimi 30 giorni)
I am trying to create a automated PowerPoint generation tool using MATLAB Report Generator.
I am unable to add a Bulleted List (using mlreportgen.ppt.Paragraph class) when I am using a template while creating the presentation. When I use a default ppt without mentioning a template the same set of lines does the work.
I am trying to achieve a format similar to this.
I am able to achieve this if I use,
import mlreportgen.ppt.*
ppt = Presentation('test.pptx'); % create a ppt named 'test'
open(ppt);
textSlide = add(ppt,'Title and Content');
para = Paragraph("First Content Slide");
para.FontColor = "blue";
replace(textSlide,"Title",para);
replace(textSlide,"Content",["First item","Second item","Third item"]);
close(ppt);
rptview(ppt);
I am unable to do the same if I use a template. The code runs without any errors but a blank presentaion is created without the bulleted items.
ppt = Presentation('test.pptx', 'template.pptx'); % template.pptx can be any Microsoft Office provided template
(The first argument to Presentation() class is the name of ppt we would like to create and the second argument is the template we would like to use)
Any suggestions to overcome this? It would also be good to know if we can apply the layouts after getting the necessary information in there.

Risposte (2)

Sean de Wolski
Sean de Wolski il 24 Set 2021
The template should not be a pptx file but a potx file.
  1 Commento
Jayanth Suresh
Jayanth Suresh il 28 Set 2021
I tried the same with template.potx and the problem still persists. I am not able to include Paragraph in a presentation created with a template

Accedi per commentare.


Rahul Singhal
Rahul Singhal il 6 Ott 2021
Hi Jayanth,
The reason for the missing data in the generated presentation, only when using the custom template, can be because of the mismatch in the placeholder names that are used in the MATLAB script than those defined in the custom template file. When the slide's replace() method is used to replace any placeholder with some content, the placeholder name being replaced should match with what is defined in the corresponding slide layout in the template file. So to fix this issue, you can either update the placeholder names in the template file or update them in the script, so that the names are consistent at both the places.
To view or update the names of placeholders in the template file, see https://www.mathworks.com/help/rptgen/ug/access-powerpoint-template-elements.html#buzo51h
Such problems can be avoided if the default PPT API template is used as the starting point to create custom templates. This link can be helpful on how to create and customize a copy of the default PPT API template: https://www.mathworks.com/help/rptgen/ug/set-up-the-powerpoint-template.html#buzlrt3-1
-Rahul

Prodotti


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by