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

조회 수: 10 (최근 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 CenterFile Exchange에서 Reporting and Database Access에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by