
MATLAB Report Generator で作成したテーブルにおいて、特定の列・行の線種を変更することはできますか?
4 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2018 年 7 月 2 日
回答済み: MathWorks Support Team
2018 年 7 月 2 日
MATLAB Report Generator のドキュメント作成において、Table を挿入しています。
このとき、テーブルの任意の列(もしくは行)の線種を変更する方法を教えてください。
採用された回答
MathWorks Support Team
2018 年 7 月 2 日
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);

0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で MATLAB Report Generator についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!