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!