Filter löschen
Filter löschen

Has anyone had success in creating a Report generator class to properly fill holes in a Word document?

12 Ansichten (letzte 30 Tage)
I have been working with the Report generator dom.api function moveToNextHole(report) to fill in content controls in a Microsoft Word ".dotx" template with no issues. However, in trying to use a class to fill in the content control holes, anything I try to populate (whether text, pictures, or any other content) just ends up at the beginning of the output document, not where the content control holes are. I found this to be true even in just trying to use the Mathworks example given in the "mlreportgen.dom.Document.fill" documentation.

Akzeptierte Antwort

Paul Kinnucan
Paul Kinnucan am 6 Okt. 2016
Bearbeitet: Paul Kinnucan am 6 Okt. 2016
To generate a report from a DOM-based document object:
  • Derive your report class from mlreportgen.dom.Document class, for example
% MyReport.m
class MyReport < mlreportgen.dom.Document
method
function rpt = MyReport(name)
rpt@mlreportgen.dom.Document(name, 'docx', 'MyTemplate');
end
end
end
  • Provide a public fill<HOLEID> method for each hole in your report template, where HOLEID is the name of the hole, for example,
class MyReport < mlreportgen.dom.Document
method
function rpt = MyReport(name)
rpt@mlreportgen.dom.Document(name, 'docx', 'MyTemplate');
end
% This method is called by mlreportgen.dom.Document's fill method.
% Do not call it yourself.
function fillReportDate(rpt)
append(rpt, date);
end
end
end
  • Create a report program (i.e., script or function) to run the report.
  • In the report program, create an instance of your report class and call its fill method (inherited from mlreportgen.dom.Document class), for example,
% runMyReport.m
rpt = MyReport('myreport');
fill(rpt);
rptview(rpt.OutputPath);

Weitere Antworten (0)

Kategorien

Mehr zu Reporting and Database Access finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by