MATLAB Report Generator で作成したテーブルに​おいて、特定の列・行​の線種を変更すること​はできますか?

5 views (last 30 days)
MATLAB Report Generator のドキュメント作成において、Table を挿入しています。
このとき、テーブルの任意の列(もしくは行)の線種を変更する方法を教えてください。

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Jul 2018
DOM table の各行にアクセスするには、テーブルの row メソッドを使用します。
・mlreportgen.dom.Table.row
各列にアクセスするには、テーブルの ColSpecGroups プロパティを使用します。
・mlreportgen.dom.Table.Table.ColSpecGroups
また、テーブルの特定のエントリにアクセスするには、テーブルの entry メソッドを使用します。
・mlreportgen.dom.Table.entry
上記のメソッドやプロパティから、Border フォーマットを指定し、線種を指定します。
・mlreportgen.dom.Border class
以下は、その実行例です。
import mlreportgen.dom.*;
d = Document('mydoc','docx');
data = magic(5);
C = num2cell(data);
C = [{'d1', 'd2', 'd3', 'd4', 'd5'}; C];
t = Table(C);
% テーブル全体のフォーマット指定
t.Style = {Border('inset','black','1px'), ...
ResizeToFitContents(true)};
% テーブルの一行目のボーダーのフォーマットを指定
bottomBorder = Border();
bottomBorder.BottomStyle = 'single';
bottomBorder.BottomColor = 'black';
bottomBorder.BottomWidth = '1px';
firstRow = t.row(1);
firstRow.Style = [firstRow.Style, {bottomBorder}];
% 一列目のボーダーのフォーマットを指定
rightBorder = Border();
rightBorder.RightStyle = 'single';
grps(1) = TableColSpecGroup;
grps(1).Style = {rightBorder};
grps(1).Span = 1;
t.ColSpecGroups = grps;
% テーブルの最初のエントリの右側とボトムボーダーの仕様を指定
firstEntryBorder = Border();
firstEntryBorder.BottomStyle = 'single';
firstEntryBorder.RightStyle = 'single';
firstEntry = t.entry(1,1);
firstEntry.Style = [firstEntry.Style, {firstEntryBorder}];
append(d,t); % 追加
close(d);
rptview(d.OutputPath);

More Answers (0)

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!