Adding sections by Report Generator doesn't work well after compiling

5 ビュー (過去 30 日間)
Inso
Inso 2019 年 12 月 27 日
コメント済み: Inso 2020 年 1 月 29 日
Hi, I'm using Report Generator in app designer to add sections to my .doc report. The code is something like :
makeDOMCompilable();
import mlreportgen.dom.*
import mlreportgen.report.*
function genrpt(app,docname)
...
app.rpt = Report(docname,'docx');
end
function gensec(app,secname,img)
...
app.sec = Section(secname);
add(app.sec,img)
end
function addsec(app,secname,addedname)
...
add(addedname,secname)
end
By calling these functions, I can generate a report like:
1.Section1
1.1 Subsection1
1.2 Subsection2
2.Section2
...
Which works fine inside app designer.
However, after it is compiled to standalone application (.exe), the numbering works incorrectly. And the generated report turns into:
1.Section1
1.1 Subsection1
1.1 Subsection2
1.Section2
...
Which confused me a lot. Can anyone help? Thx!

回答 (3 件)

Inso
Inso 2019 年 12 月 27 日
編集済み: Inso 2020 年 1 月 15 日
I just wrote a simple example to illustrate the problem:
f=waitbar(0,'waiting') ;
makeDOMCompilable();
import mlreportgen.dom.*
import mlreportgen.report.*
waitbar(0.2,f,'waiting')
rpt = Report('test','docx');
sec1 = Section('Section1');
waitbar(0.4,f,'waiting')
subsec1= Section('subSection1');
add(subsec1,'Weather is good') ;
add(sec1,subsec1) ;
waitbar(0.6,f,'waiting')
subsec2= Section('subSection2');
add(subsec2,'Let''s go hiking') ;
add(sec1,subsec2) ;
waitbar(0.8,f,'waiting')
add(rpt,sec1) ;
close(rpt)
waitbar(1,f,'waiting')
rptview(rpt);
close(f)
you can copy and run it. After compling the .mlapp or .m file, the numbering won't work.
  1 件のコメント
Inso
Inso 2020 年 1 月 9 日
編集済み: Inso 2020 年 1 月 9 日
Just tried the scripts in 2019b. Still got the same issue (not numbering after compiling). What happened?

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


Inso
Inso 2020 年 1 月 10 日
編集済み: Inso 2020 年 1 月 10 日
Also tried the example 'Number Section Headings, Table Titles, and Figure Captions Programmatically' in matlab documentation, which uses DOM API and 'getChapterTitle' function. It returns 'can't find the function 'getChapterTitle' for string type input'.

Vijay A
Vijay A 2020 年 1 月 25 日
編集済み: Vijay A 2020 年 1 月 25 日
You need to create your own template as per your need I guess. Please refer to the manual on how to preapre your own template.
have a try with pdf format . I am not sure but have a try because MATLAB can generate reprots perfectly for N-Number of pages in PDF format and word doc has some limitations.
makeDOMCompilable();
import mlreportgen.dom.*
import mlreportgen.report.*
function genrpt(app,docname)
...
app.rpt = Report(docname,'pdf');
end
function gensec(app,secname,img)
...
app.sec = Section(secname);
add(app.sec,img)
end
function addsec(app,secname,addedname)
...
add(addedname,secname)
end
  1 件のコメント
Inso
Inso 2020 年 1 月 29 日
Yeah, pdf version works fine. But I need editable report :(
Also I'm afraid template is not a solution, since it is the user that decide the number/order of the sections.
Thanks for your help!

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

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by