Error with compiled app designer app using report generator toolbox.

7 次查看(过去 30 天)
Big picture, I am using app designer to write data processing apps for the laboratory where I work. The apps use base Matlab (v 2022b) and report generator to create data sheets for our reports. I am attempting to use Matlab Compiler to compile these into standalone desktop apps that I can distribute to my group. The apps run fine in the Matlab environment, but all encounter an error when trying to create a report sheet in the compiled version.
An excerpt from the code is shown below. The error occurs at some point during the execution of this code in the compiled app. As a side question, is it possible to see an error log in the compiled app (similar to how errors would be shown in the command window while working in the Matlab environment)?
I suspect that the error is occuring when the program tries to find the template path in the compiled version or when the document command is executed. All the template files are bundled with the compiled app installer.
makeDOMCompilable();
import mlreportgen.report.*
import mlreportgen.dom.*
%user prompt to enter name of generated report file
prompt = {'Enter File Name:'};
dlgtitle = 'Input';
dims = [1 35];
definput = {''};
Filename = inputdlg(prompt,dlgtitle,dims,definput);
Filename = string(Filename);
%Locate template file and generate full path
whoAmI = mfilename('fullpath');
[fullpath, ~, ~] = fileparts(whoAmI);
template = fullfile(fullpath,'Templates','SwellC_Template_New.dotx');
% I suspect this is the line where the code is encountering an
% error.
D = Document(Filename,'docx', template);
%There is more code in the block below to finish populating the
%template, but this is the general format.
open(D)
moveToNextHole(D);
append(D, app.ProjectEditField.Value);
moveToNextHole(D);
append(D, app.FeatureEditField.Value);
moveToNextHole(D);
append(D, app.IndexEditField.Value);
moveToNextHole(D);
append(D, app.BoreholeEditField.Value);
moveToNextHole(D);
%...
close(D);
f = msgbox("Report Generation Complete");

采纳的回答

Githin George
Githin George 2023-12-13
Hello Richard Bearce,
It is my understanding that you are facing an issue when compiling an application into a standalone desktop app and you would like to see an error log for the compiled application.
The MATLAB Compiler provides an option to enable output log in the "Additional Runtime Settings" section. Please refer to the link below to view the detailed instructions to enable this setting.
In addition, you could use a try, catch statement to handle the errors in your code. Please refer to documentation link below for examples.
I hope this helps resolve your issue.
  2 个评论
RGB85
RGB85 2023-12-15
Thank you for the response. I tried using the error log feature but it did not generate any log file. I did some more reading in the threads linked below and it looks like there's an issue with this feature. I'm not sure if anything has been done to fix it, but I was not able to get any of the proposed solutions to work.
Githin George
Githin George 2023-12-27
The error log appers to be generating in windows without any issues. The comments in the above thread mentions a way to open the compiled application from the terminal such that the error log is generated. Or as a workaround the usage of "diary" function is also proposed. Were you able to try out any of these methods?
Also could you try writing the output of try-catch block into a file instead of using the logs.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Report Generator 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by