Report generator issue on standalone application
古いコメントを表示
I am having a big problem. When I use the following line:
report = Document(docname,'html-file');
or
report = Document(docname,'docx');
on workspace it works well, then I compile this gui to a standalone application and I run .exe, but this .exe(standalone application) always fails there.
I really do not know how to correct it, because using matlab it works well and I need to use it on another computer without matlab.
Thanks
回答 (2 件)
Vijay A
2020 年 1 月 25 日
Hello Danilo Teran
Initially i had the same problem, you must use the following code to rectify the issue :
- Using makeDOMCompilable()
Use the makeDOMCompilable() function in the begning of the program where you need to generate the report.
makeDOMCompilable();
import mlreportgen.dom.*
import mlreportgen.report.*
d = Document("mydoc",'pdf');
open(d);
2. Make sure you have the corresponding version of the matlab runtime installed in your PC.
In order to find the version of your matlab just type ver in your command prompt to check for your matlab version
code to find the matlab version is given below
ver
Click on the link below to move to the download section of the respective MATLAB runtime
Make sure the MATLAB Runtime is installed in the PC where you are using the exe standalone application and you need to install the same version of the MATLAB Runtime where the matlab codes are generated.
3. First compile a simple application without any external arguments to check :
makeDOMCompilable();
import mlreportgen.dom.*
import mlreportgen.report.*
d = Document("myDoc1", "pdf");
open(d);
append(d, Heading1("Spacing Using OuterMargin"));
p1 = Paragraph("This is a paragraph with a bottom outer margin of 50pt.");
p1.Style = {OuterMargin("0pt", "0pt","0pt","50pt")};
append(d, p1);
p2 = Paragraph("This is a paragraph with a bottom outer margin of 25pt.");
p2.Style = {OuterMargin("0pt", "0pt","0pt","25pt")};
append(d, p2);
p3 = Paragraph("This is a paragraph with a bottom outer margin of 5pt.");
p3.Style = {OuterMargin("0pt", "0pt","0pt","5pt")};
append(d, p3);
append(d, Text("Text to show spacing"));
close(d);
rptview(d);
4. If the above method does not work just text me or inbox me will give you another solution. I have face issues like this initially but now i resolved the issue.
Good luck
2 件のコメント
Sreejith Themath
2020 年 5 月 16 日
編集済み: Walter Roberson
2025 年 1 月 6 日
I request your support:
I have written some code for my project work.
When I am Running from Matlab environemt Its woking fine. However when I make a standaloe app ots showing the following error
Error using mlreportgen.ppt.Presentation/add
Unable to check out a Report Generator license. Reason: ''
I checked and confirmed that I have valid Report generator license.
I have written makeDOMCompilable(); on top of my code.
I have installed the lattest matlab run time.
Can you help me to debug this issue.
makeDOMCompilable();
import mlreportgen.ppt.*
slidesFile = basic.pptname;
slides = Presentation(slidesFile,'Template.pptx');
slide_no=1;
para = Paragraph("Base data");
data= Paragraph(data_txt);
slide(slide_no) = add(slides,'Content');
replace(slide(slide_no),'Title',para);
replace(slide(slide_no),'Content',data);
close(slides);
Rahul Singhal
2020 年 5 月 22 日
Hi Sreejith,
To compile a PPT API program, you will have to use makePPTCompilable() instead. See https://www.mathworks.com/help/rptgen/ug/compile-a-presentation-program.html
Thanks,
Rahul
Vijay A
2020 年 1 月 21 日
0 投票
Have you figured out this issue plesae inbox me
5 件のコメント
farzad
2020 年 5 月 21 日
編集済み: Walter Roberson
2025 年 1 月 6 日
may you please check my question here ?
Jorge Torres
2020 年 12 月 17 日
Hi Vijay,
Currently, I'm programming a standalone app using App Designer using R2020b; also I know that I have downloaded the correct version for MC Runtime (9.9).
I have a similar "problem" like yours when you published January 8, 2020, a message in response to the "Matlab Report Generator to be used on Standalone application" question; my program doesn't generate a report in the ".exe" file. Testing, I notice that I have execution problems when I tried to include images in my report generatir in App Designer. Sincerely, I don't know how to use the "templatePath" function that you used proved in that message, and I suppouse that I have problems with path relatives for the images.
Here is my code for generate a report. The comment lines together (just after to "%Start to format the designs of the images" are the execution problem, without them the report in exe file works fine.
Could you help me pleae?.
function Button_GetReport_T1Pushed(app, event)
% Generationg word file!
makeDOMCompilable();
% import DOM and Report API
import mlreportgen.report.*;
import mlreportgen.dom.*;
% Create a container for a WORD report
doctype = 'docx';
rpt = Report('DGA_DuavalTriangle_1_report', doctype);
open(rpt);
% Create Title Page
tp = TitlePage();
tp.Title = 'Dissolved gas-in-oil analysis';
tp.Subtitle = 'Application of Duval Triangle 1 Report';
tp.Author = 'Jdtorres';
tp.PubDate = date();
% Add Title Page to report
append(rpt, tp);
% Create Table of contents
toc = TableOfContents;
% Add Table of contents to report
append(rpt, toc);
% Create a chapter with a title
ch1 = Chapter('Oil Analysis Report');
% Create a chapter with a title
ch1 = Chapter('Oil Analysis Report');
% Create a section with a title
s1 = Section('Reference');
s2 = Section('Equipment');
s3 = Section('Dissolved gas-in-oil analysis');
s4 = Section('Diagnosis and recommendations');
% Insert text
t1 = Text(['References and bla.. bla.. ']);
t2 = Text('Characteristics of the transformer tested are described below:');
t3 = Text(['This Disolved Gas Analysis report contains the ' ...
'detailed analysis bellow:']);
t3_2 = Text(['The Duval relative % for each gas %C2H2=100x/(x+y+z); ' ...
' %C2H4=100y/(x+y+z); %CH4=100y/(x+y+z):']);
% Start to format the designs of the images
% copyUIAxes(app.UIAxes); % Key!
% saveas(gcf, 'Triangle1Photo.png');
% % Add a formal Image to the report
% image = mlreportgen.report.FormalImage();
% image.Image = which('Triangle1Photo.png');
% image.Caption = 'Duval Triangle 1 Figure';
% image.ScaleToFit(true);
% delete(gcf);
% Add text to the section report
append(s1,t1);
append(s2,t2);
add(s3,t3); append(s3,t3_2); %append(s3, image);
append(ch1,s1);
append(ch1,s2);
append(ch1,s3);
append(ch1,s4);
append(rpt, ch1);
% Close editor ando view the report
close(rpt);
rptview(rpt);
end
CopyUIAxes(app.UIAxes) is a function that makes a screenshot for an image call app.UIAxes. The section comment doesn't work with all the code maybe because I fault when I have to set a path directory for the image.
Could you help me?
Adam Danz
2020 年 12 月 18 日
If you aren't getting an error message, could you describe the problem with the commented section?
RGB85
2023 年 12 月 15 日
I know this post is a few years old, but I'm having the same problem. I copied the code for the simple application above, compiled it, and the resulting app would not generate the report. I'm using a similar approach in one of my apps which is how I found this thread. As far as I can tell, the document command does not work in a compiled app. Is there any solution to this issue?
Walter Roberson
2025 年 1 月 6 日
Dear RGB85 Could you solve your problem? I have the same problem and cant find how to fix it
カテゴリ
ヘルプ センター および File Exchange で MATLAB Report Generator Task Examples についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!