Report only showing names of the objects instead of their content

조회 수: 5 (최근 30일)
Hello everyone!
I have a code generating a full report. But now the word file only gives me the name of the objects in the report and not the actual content like this:
Capture.PNG
Do anyone know where does this problem comes from?
My code is
rpt = Document('Report','docx');
%% title page generation
tp = TitlePage;
tp.Title = 'Report';
tp.Subtitle = 'This report is generated from the test.';
tp.Author = 'Jack'
append(rpt, tp);
%% Summary
ChapterRegression = Chapter;
ChapterRegression.Title = 'Summary';
append(rpt, ChapterRegression)
close(rpt)
My dotx template just have one Rich Text Content Control hole.
Thank you in advance!

채택된 답변

Rahul Singhal
Rahul Singhal 2019년 7월 25일
You can not add Report API objects like TitlePage to a DOM Document. Use mlreportgen.report.Report instead of the DOM Document. You can add both DOM and Report API objects to a Report object.
  댓글 수: 4
Jack Arnoldi
Jack Arnoldi 2019년 7월 25일
I am sorry to bother.. but it is not explained how I should use this. For example
moveToNextHole(rpt.Document);
or
rpt.Document.CurrentPageLayout;
will give me an error, and I can't find anything about working with "underlying object" in Matlab...
Rahul Singhal
Rahul Singhal 2019년 7월 25일
I tried with the sample code below:
import mlreportgen.report.*
import mlreportgen.dom.*
% Create a report with custom template with a hole in it.
rpt = Report('output', 'pdf', 'myTemplate.pdftx');
open(rpt);
% Get the underlying DOM Document object and update the page size
doc = rpt.Document;
doc.CurrentPageLayout.PageSize.Height = '16in';
doc.CurrentPageLayout.PageSize.Width = '11in';
% Move to the custom hole and add content to it
doc.moveToNextHole();
add(rpt, Paragraph("Content to go in custom hole"));
% Close and view the report
close(rpt);
rptview(rpt);
If you are still getting an error, can you please share the error message.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by