how to add title/caption to FormalTable ?

조회 수: 14 (최근 30일)
SRUSHTI KHATAU
SRUSHTI KHATAU 2021년 11월 20일
댓글: SRUSHTI KHATAU 2021년 11월 25일
I want to add caption/title to the table. I am making tables using FormalTable but could not find the property to add caption to it. Please help

채택된 답변

Srijith Kasaragod
Srijith Kasaragod 2021년 11월 23일
Hi Srushti,
Please refer this answer which captures the same issue.
Regards.
  댓글 수: 3
Srijith Kasaragod
Srijith Kasaragod 2021년 11월 25일
편집: Srijith Kasaragod 2021년 11월 25일
Base table provides an option to specify a numbered title to the table. So inorder to add a title to a Formal table, you can first create a Formal table and then create a Base table from it. The following piece of code shows an example:
import mlreportgen.dom.*
import mlreportgen.report.*
%Create a report
rpt = Report("mydoc","pdf");
open(rpt);
%Create a FormalTable
t = FormalTable({'Col1', 'Col2'}, {'entry11', 'entry12'; 'entry21', 'entry22'});
tableStyles = { ColSep("solid"), ...
RowSep("solid"), ...
Border("solid"), ...
Width("4in")};
% Specify styles for the header first row
headerRow = t.Header.Children(1);
headerRow.Style = [headerRow.Style {Bold()}];
%Create BaseTable from FormalTable and add to report
chapter = Chapter();
chapter.Title = "Table example";
add(rpt,chapter);
table = BaseTable(t);
table.Title = "Formal table to Base table";
add(rpt,table);
%Close and view report
close(rpt);
rptview(rpt);
Hope this helps!
SRUSHTI KHATAU
SRUSHTI KHATAU 2021년 11월 25일
Thank you so much.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator Task Examples에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by