Matlab Report generator help

1 view (last 30 days)
Caleb Darr
Caleb Darr on 6 Aug 2020
Commented: Caleb Darr on 7 Aug 2020
Using Matlab add-on "Report Generator" I am trying to create a matlab script where I can import my results from a lab and generate a report with the given figures, tables, and graphs. I am not having difficulty importing my data into the file, but I have having trouble formatting my lab report. For instance when creating a title page I am able to add the title, author, publisher, and publication date with the built in functions; however, I am have difficulty adding more to this page for instance additional contributors, course number, instructor, etc. How can I add these text items and then format the font, size, color, text positon on page (centered, right align, or left align).
Additionally how to I add headers and footers. In general I feel like I am lacking the knowledge of how to use Report Generator and if available general library of code could help in developing my script.
% Import report API classes
import mlreportgen.report.*
import mlreportgen.dom.*
% Add report container
doctype = 'docx'; % docx, pdf, html
reportname = 'LabReport'
R = Report(reportname, doctype);
% Title Page
% Enter required information into the title page
publisher = 'Name';
title = 'Title of Lab';
author = 'Written by: Name';
contr1 = 'First Last, email';
contr2 = 'First Last, email';
contr3 = 'First Last, email';
contr4 = 'First Last, email';
date = 'DOW #:## pm -- Date';
course = ' ###: Name';
inst = 'Dr. ****, email (###)###-####';
tA = 'Name, email';
tp = TitlePage;
tp.Title = title;
tp.Author = author;
tp.Publisher = publisher;
tp.PubDate = date;
add(R, tp);

Answers (1)

Rahul Singhal
Rahul Singhal on 6 Aug 2020
Hi Caleb,
To add more information to the title page, you will have to customize the TitlePage reporter class. Use mlreportgen.report.TitlePage.customizeReporter method to create a custom title page class. This will also copy all the default title page templates. Then add properties in this custom class for each additional infomation you wish to add. You will also have to customize the templates to add a hole corresponding to each newly added property.
The below link describes, with sample code, on how to customize the Chapter reporter class to add more information as I mentioned above. In the same way you can customize the TitlePage reporter class.
The above link also has information on customizing the chapter page headers.
Thanks,
Rahul
  1 Comment
Caleb Darr
Caleb Darr on 7 Aug 2020
Thank you very much Rahul for the help, I am working on learning how to utilize your suggestions
Best,
Caleb

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!