Save report HTML file from HTMX

21 ビュー (過去 30 日間)
K W
K W 2019 年 3 月 19 日
コメント済み: K W 2019 年 3 月 21 日
Hi there,
How do I save an HTML report as an HTML file?
import mlreportgen.report.*
reportPath = fullfile(pwd, 'MyReportName');
rpt = mlreportgen.report.Report(reportPath,'html');
ch = Chapter;
ch.Title = 'Title string';
myReportTable = mlreportgen.dom.FormalTable(cellArrayOfStrings,matlabTable);
add(ch,myReportTable);
add(rpt,ch);
rptview(rpt)
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.
  2 件のコメント
madhan ravi
madhan ravi 2019 年 3 月 21 日
Heard of publish() ?
K W
K W 2019 年 3 月 21 日
編集済み: K W 2019 年 3 月 21 日
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 = mlreportgen.report.Report(reportPath,'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']);
show(docobj);
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.

サインインしてコメントする。

採用された回答

Mary Abbott
Mary Abbott 2019 年 3 月 21 日
To generate a report as a single HTML file, set the report type to html-file.
rpt = mlreportgen.report.Report(reportPath,'html-file');
More details about the different types of reports can be found at the following link:
  1 件のコメント
K W
K W 2019 年 3 月 21 日
Yes! Thank you! Not sure how I missed that.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Report Generator についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by