How can I change the background color of a cell in report generator?
16 ビュー (過去 30 日間)
古いコメントを表示
I am very new in the report generator toolbox, but hopefully someone can help me here
I am generating a table via report generator, but if i have this table:
T = [1 2 6; 3 4 10; 2 5 10]
is it possible to color the cell so values <10 turns green, >10 & <20 turns yellow, and >20 turns red in the output report?
Thanks a lot in advance
0 件のコメント
回答 (1 件)
Mary Abbott
2019 年 3 月 13 日
You can change how a particular number is formatted in a table by setting properties of a Text object that contains the number. For example, the following code creates a Text object for an entry in T and sets the BackgroundColor property to green. It creates a table using the Text object and the remaining numbers in T:
% Make T a cell array so that we can replace a number with a Text object
T = {1 2 6; 3 4 10; 2 5 10};
% Replace the number 6 with a Text object
textObj = mlreportgen.dom.Text(T{1,3});
textObj.BackgroundColor = "green";
T{1,3} = textObj;
% Create a Table from the Text objects and add to a report
tbl = mlreportgen.dom.Table(T);
More information about the mlreportgen.dom.Text class along with other formatting options can be found at the following link:
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!