Powerpoint Generation MATLAB App Issues
21 views (last 30 days)
Show older comments
I have created a MATLAB Application with App Designer and it outputs the powerpoint correctly within App Designer but then once I had compiled it, created it as a MATLAB App that I can then install as an app in MATLAB and then run the app, the powerpoint won't be generated properly and it will cause an error. It saves the file where I want it to but the powerpoint will give an error when I try to open. You can see the error message in the image below. It tells me to repair and once I click on it, the powerpoint will be empty but it should have 7 slides full of information. I have tried the code with the 'makePPTCompilable()' and without it and it still doesn't work.
%/////////////////// PowerPoint //////////////
% Create a presentation
makePPTCompilable();
import mlreportgen.ppt.*
ppt = Presentation("Pulse Violation Report.pptx");
open(ppt);
Background = Picture('StellantisBackground.png');
Background.Width = '13.33in';
Background.Height = '7.51in';
Heading = Picture('StellantisHeading.png');
Heading1 = Picture('StellantisHeading.png');
Heading2 = Picture('StellantisHeading.png');
Heading3 = Picture('StellantisHeading.png');
Heading4 = Picture('StellantisHeading.png');
Heading5 = Picture('StellantisHeading.png');
Heading6 = Picture('StellantisHeading.png');
Heading7 = Picture('StellantisHeading.png');
Logo = Picture('StellantisLogo.png');
Logo1 = Picture('StellantisLogo.png');
Logo2 = Picture('StellantisLogo.png');
Logo3 = Picture('StellantisLogo.png');
Logo4 = Picture('StellantisLogo.png');
Logo5 = Picture('StellantisLogo.png');
Logo6 = Picture('StellantisLogo.png');
Logo7 = Picture('StellantisLogo.png');
% Add a slide to the presentation
slide = add(ppt,'Blank');
add(slide,Background);
titleTB = TextBox();
titleTB.X = '2.83in';
titleTB.Y = '2.85in';
titleTB.Height = '2.61in';
titleTB.Width = '10in';
titleTB.Style = {FontSize('60pt'),Bold(true),FontColor('white')};
add(titleTB, 'Pulse Violation Report');
add(slide,titleTB);
username = TextBox();
username.X = '0.3in';
username.Y = '0.3in';
username.Width = '4in';
username.FontColor = 'white';
name = app.NameEditField.Value;
add(username,name);
add(slide,username);
userTID = TextBox();
userTID.X = '0.3in';
userTID.Y = '0.6in';
userTID.Width = '4in';
userTID.FontColor = 'white';
TID = app.TIDEditField.Value;
add(userTID,TID);
add(slide,userTID);
userdate = TextBox();
userdate.X = '0.3in';
userdate.Y = '0.9in';
userdate.Width = '4in';
userdate.FontColor = 'white';
date = app.DateEditField.Value;
add(userdate,date);
add(slide,userdate);
Temp = TextBox();
Temp.X = '0in';
Temp.Y = '6.7in';
Temp.Height = '0.43in';
Temp.Width = '10in';
Temp.Style = {FontColor('white')};
temp = string(app.TemperatureEditField.Value);
temp_final = append("Temperature:",' ',temp);
add(Temp,temp_final);
add(slide,Temp);
subtitleTB = TextBox();
subtitleTB.X = '0in';
subtitleTB.Y = '7.07in';
subtitleTB.Height = '0.43in';
subtitleTB.Width = '10in';
subtitleTB.Style = {FontColor('white')};
add(subtitleTB, value);
add(slide,subtitleTB);
slide7 = add(ppt,'Title and Content');
Heading7.X = '0.3in';
Heading7.Y = '0.19in';
Heading7.Height = '0.47in';
Heading7.Width = '10.82in';
Logo7.X = '11.27in';
Logo7.Y = '0.09in';
Logo7.Height = '0.69in';
Logo7.Width = '1.95in';
add(slide7, Heading7);
add(slide7, Logo7);
Information = Paragraph("All violations are displayed in this PowerPoint" + newline + "Each slide of this report contains all of the violation information for a specific type of pulse" + newline + "Pulse_Num refers to the pulse cluster it occurs in, and corresponds to an SOC level" + newline + "For example, if the Pulse_num is 1, that means it is the first pulse of its type to occur, and occurs at the same SOC level as all other pulses with Pulse_Num of 1" + newline + "Non-consecutive power violations which do not exceed the 20% limit are not included, as they do not count as real violations");
Information.FontSize = '20';
replace(slide7, "Content",Information);
replace(slide7, "Title",'Preliminary Information');
%Adding Table in PP
slide1=add(ppt,'Title and Table');
contents=find(ppt,'Table');
replace(slide1,'Title','Instant Discharge Pulse Overview');
table1=Table(TwoSecPulseSummaryTable);
table1.Style = {FontSize('10pt'),Bold(true),FontColor('Black')};
table1.StyleName = 'Medium Style 2 - Accent 1';
replace(contents,table1);
Heading1.X = '0.3in';
Heading1.Y = '0.19in';
Heading1.Height = '0.47in';
Heading1.Width = '10.82in';
Logo1.X = '11.27in';
Logo1.Y = '0.09in';
Logo1.Height = '0.69in';
Logo1.Width = '1.95in';
add(slide1, Heading1);
add(slide1, Logo1);
slide2=add(ppt,'Title and Table');
contents2=find(ppt,'Table');
replace(slide2,'Title','Short Discharge Pulse Overview');
table2=Table(TenSecPulseSummaryTable);
table2.Style = {FontSize('10pt'),Bold(true),FontColor('Black')};
table2.StyleName = 'Medium Style 2 - Accent 1';
replace(slide2,'Table',table2);
Heading2.X = '0.3in';
Heading2.Y = '0.19in';
Heading2.Height = '0.47in';
Heading2.Width = '10.82in';
Logo2.X = '11.27in';
Logo2.Y = '0.09in';
Logo2.Height = '0.69in';
Logo2.Width = '1.95in';
add(slide2, Heading2);
add(slide2, Logo2);
slide3=add(ppt,'Title and Table');
contents3=find(ppt,'Table');
replace(slide3,'Title','Long Discharge Pulse Overview');
table3=Table(ThirtySecPulseSummaryTable);
table3.Style = {FontSize('10pt'),Bold(true),FontColor('Black')};
table3.StyleName = 'Medium Style 2 - Accent 1';
replace(slide3,'Table',table3);
Heading3.X = '0.3in';
Heading3.Y = '0.19in';
Heading3.Height = '0.47in';
Heading3.Width = '10.82in';
Logo3.X = '11.27in';
Logo3.Y = '0.09in';
Logo3.Height = '0.69in';
Logo3.Width = '1.95in';
add(slide3, Heading3);
add(slide3, Logo3);
slide4=add(ppt,'Title and Table');
contents4=find(ppt,'Table');
replace(slide4,'Title','Instant Charge Pulse Overview');
table4=Table(CHGTwoSecPulseSummaryTable);
table4.Style = {FontSize('10pt'),Bold(true),FontColor('Black')};
table4.StyleName = 'Medium Style 2 - Accent 1';
replace(slide4,'Table',table4);
Heading4.X = '0.3in';
Heading4.Y = '0.19in';
Heading4.Height = '0.47in';
Heading4.Width = '10.82in';
Logo4.X = '11.27in';
Logo4.Y = '0.09in';
Logo4.Height = '0.69in';
Logo4.Width = '1.95in';
add(slide4, Heading4);
add(slide4, Logo4);
slide5=add(ppt,'Title and Table');
contents5=find(ppt,'Table');
replace(slide5,'Title','Short Charge Pulse Overview');
table5=Table(CHGTenSecPulseSummaryTable);
table5.Style = {FontSize('10pt'),Bold(true),FontColor('Black')};
table5.StyleName = 'Medium Style 2 - Accent 1';
replace(slide5,'Table',table5);
Heading5.X = '0.3in';
Heading5.Y = '0.19in';
Heading5.Height = '0.47in';
Heading5.Width = '10.82in';
Logo5.X = '11.27in';
Logo5.Y = '0.09in';
Logo5.Height = '0.69in';
Logo5.Width = '1.95in';
add(slide5, Heading5);
add(slide5, Logo5);
slide6=add(ppt,'Title and Table');
contents6=find(ppt,'Table');
replace(slide6,'Title','Long Charge Pulse Overview');
table6=Table(CHGThirtySecPulseSummaryTable);
table6.Style = {FontSize('10pt'),Bold(true),FontColor('Black')};
table6.StyleName = 'Medium Style 2 - Accent 1';
replace(slide6,'Table',table6);
Heading6.X = '0.3in';
Heading6.Y = '0.19in';
Heading6.Height = '0.47in';
Heading6.Width = '10.82in';
Logo6.X = '11.27in';
Logo6.Y = '0.09in';
Logo6.Height = '0.69in';
Logo6.Width = '1.95in';
add(slide6, Heading6);
add(slide6, Logo6);
%Plotting the Power Summary Plot
%figure(1)
f_1 = figure('Visible','Off');
plot(app.time, app.PP,'b')%Pack Power
grid on
xticks([0 10000 20000 30000 40000 50000 60000 70000 80000 90000 100000 110000 120000 130000 140000 150000])
xticklabels({'x = 0','10000','20000','30000','40000','50000','60000','70000','80000','90000','100000','110000','120000','130000','140000','150000'})
xlabel('Time (s)')
ylabel('Power (kW)')
title('Pack Power Charge -Neg- and Discharge -Pos-');
legend('Pack Power')
legend('boxoff');
legend('Location','southoutside');
%Adding the generated plot to the slide; in this case, slide 7, though
%actually slide 8 in the real PowerPoint due to not counting the title
%slide
img1 = 'plot1.png';
saveas(f_1,img1);
% Close the presentation
close(ppt);
% View the presentation
%rptview(ppt);
0 Comments
Answers (1)
Kevin Holly
on 18 Sep 2023
Ratanjot,
Try writing the full path to your image files and see if that resolves the issue.
I am assuming you are receiving this error when creating your PowerPoint:
Caught "std::exception" Exception message is:
createInputStream failed: No such file or directory
0 Comments
See Also
Categories
Find more on MATLAB Report Generator in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!