Borrar filtros
Borrar filtros

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

6 visualizaciones (últimos 30 días)
Inso
Inso el 27 de Dic. de 2019
Comentada: Inso el 29 de En. de 2020
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!

Respuestas (3)

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

Iniciar sesión para comentar.


Inso
Inso el 10 de En. de 2020
Editada: Inso el 10 de En. de 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 el 25 de En. de 2020
Editada: Vijay A el 25 de En. de 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 comentario
Inso
Inso el 29 de En. de 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!

Iniciar sesión para comentar.

Categorías

Más información sobre Reporting and Database Access en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by