How to add sections to PowerPoint with MATLAB Report Generator

조회 수: 10 (최근 30일)
Ruixin Zhou
Ruixin Zhou 2019년 6월 25일
댓글: Andreas 2023년 2월 10일
In order to achieve cross platform capability, I've been using the MATLAB Report Generator toolbox to manipulate PowerPoint presentation programmatically. I was going to organize the presentation structure by adding sections to it.
Here is an equivalent MWE with ActiveX on Windows:
% invoke activex server
ppt = actxserver('powerpoint.application');
% add a presentation
ppt.Presentations.Add();
% choose a layout
layout = ppt.ActivePresentation.SlideMaster.CustomLayouts.Item(1);
% add slide 1 and section 1
ppt.ActivePresentation.Slides.AddSlide(1, layout);
ppt.ActivePresentation.SectionProperties.AddBeforeSlide(1,'mySection1');
% add slide 2 and section 2
ppt.ActivePresentation.Slides.AddSlide(2, layout);
ppt.ActivePresentation.SectionProperties.AddBeforeSlide(2,'mySection2');
I would like to get the same thing done with Report Generator..

채택된 답변

Rahul Singhal
Rahul Singhal 2019년 6월 26일
Hi Ruixin,
Currently, the MATLAB Report Generator's PPT API does not support creating sections programmatically.
The team plans to add this functionality in the future releases.
Alternatively, as a workaround, you can add sections in your template presentation with maybe a single slide in each section, for e.g., a Section Header slide. Then generate your new presentation using this template presentation and add the new slides using the index number, which represents the position of this new slide in the generated presentation. See https://www.mathworks.com/help/rptgen/ug/mlreportgen.ppt.presentation.add.html
For example, create a template presentation, named input.pptx, with 2 sections where each section consists of a single section header slide, as shown below:
section.JPG
Now create your output presentation using this input presentation as shown below:
ppt = mlreportgen.ppt.Presentation("output.pptx", "input.pptx");
open(ppt);
% Add slide to Section1.
% Specify the index as 2 as this needs to be inserted after the
% Section 1 header slide which is present at index 1.
sect1Slide = add(ppt,'Title and Content',2);
% Add slide to Section2.
% Specify the index as 4 as this needs to be inserted after the
% Section 2 header slide which is now present at at index 3.
sect2Slide = add(ppt,'Title and Content',4);
close(ppt);
rptview(ppt);
The generated output presentation looks like:
output.JPG
Hope this helps!
Thanks,
Rahul
  댓글 수: 1
Andreas
Andreas 2023년 2월 10일
Hello Rahul, I didn't get your result and opened my own question to tackle it. If you would give a look I would appreciate it: https://www.mathworks.com/matlabcentral/answers/1910620-powerpoint-api-handling-ppt-sections

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by