MATLAB: How to access the name, path, extension or format of the report being generated in MATLAB Report Generator 3.2.1 (R2007b)

extensionMATLAB Report Generatornamepathreport

I am creating a report in MATLAB Report Generator and would like to know how I can include the name, path, extension and format of the current report being generated.

Best Answer

In order to include this information in a report you will need to write a custom component that extracts this data from the XML structure which is used when the document is generated. The execute() function of the report should contain the following code:
function out=execute(thisComp,parentDoc,varargin)
% Find root of report object
root = thisComp;
while ~isempty(root.getParent)
% We have not arrived at the top level yet, so go up once more
root = root.getParent;
end
% Get the current report
report = root.getCurrentRpt;
% Obtain data from report object
keyboard
[p,n,e] = fileparts(report.getChunkFileName);
% The filename of the report
reportName = n;
% The extension of the report
reportExtension = e;
% The directory name in which the report is generated
reportDirectory = report.getrptname;
% The format of the report
outputformat = report.getPropValue('Format');
% Add something useful here to out before quitting
out =[];
Related Question