MATLAB Answers

Save report HTML file from HTMX

36 views (last 30 days)
K W on 19 Mar 2019
Commented: K W on 21 Mar 2019
Hi there,
How do I save an HTML report as an HTML file?
reportPath = fullfile(pwd, 'MyReportName');
rpt =,'html');
ch = Chapter;
ch.Title = 'Title string';
myReportTable = mlreportgen.dom.FormalTable(cellArrayOfStrings,matlabTable);
When I generate a PDF report (in the code above, line 3 would have 'pdf' instead of 'html' as input), it saves the PDF file at the location of reportPath, but when I generate it in HTML format, the file created is HTMX which I cannot open outside of MATLAB.
Thanks in advance.


madhan ravi
madhan ravi on 21 Mar 2019
Heard of publish() ?
K W on 21 Mar 2019
Unfortunately this does not help. I am not trying to publish MATLAB code, I am trying to get the report file from the report generation toolbox.
In the code above, if line 3 were changed to
rpt =,'pdf');
then rpt would exist as a PDF file that can be opened independent of MATLAB.
However, if rpt is created for HTML, then its file extension is .htmx, not .html. I would like it to be HTML.
Similarly, using
docobj = mlreportgen.utils.HTMXDoc([reportPath '.htmx']);
does not save an HTML file, it merely opens the htmx somehow as root.html but I would have to manually save it from the window, whereas I want to programmatically save the HTML file.

Sign in to comment.

Accepted Answer

Mary Abbott
Mary Abbott on 21 Mar 2019
To generate a report as a single HTML file, set the report type to html-file.
rpt =,'html-file');
More details about the different types of reports can be found at the following link:

  1 Comment

K W on 21 Mar 2019
Yes! Thank you! Not sure how I missed that.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by