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

4 visualizzazioni (ultimi 30 giorni)
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!

Risposte (3)

Inso
Inso il 27 Dic 2019
Modificato: Inso il 15 Gen 2020
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 Commento
Inso
Inso il 9 Gen 2020
Modificato: Inso il 9 Gen 2020
Just tried the scripts in 2019b. Still got the same issue (not numbering after compiling). What happened?

Accedi per commentare.


Inso
Inso il 10 Gen 2020
Modificato: Inso il 10 Gen 2020
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 il 25 Gen 2020
Modificato: Vijay A il 25 Gen 2020
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 Commento
Inso
Inso il 29 Gen 2020
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!

Accedi per commentare.

Categorie

Scopri di più su Reporting and Database Access in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by