Conditional formatting for MATLAB Report Generator Table
7 次查看(过去 30 天)
显示 更早的评论
I'm generating a report using MATLAB Report Generator and I've created a FormalTable() object and populated it with a m x n cell array of data. I've been trying to conditionally format the cells with no success. I can't seem to find a way to access individual cells of the FormalTable() to set a BackgroundColor property (or any other formatting property). Any style format objects I assign to FormalTable() properties such as TableEntriesStyle or Style set that format globally for the entire table.
The workaround is to rather create a m*n series of Text() objects for which I can individually set format properties based on some condition. The challenge is then aligning those text objects on the page to resemble a table. I cannot seem to find how to set the size and location properties of a text object in order to place it on a page.
Any suggestions on how to create a conditionally formatted table for a MATLAB report?
0 个评论
回答(1 个)
Krishnan Ramkumar
2016-12-8
编辑:Krishnan Ramkumar
2016-12-8
You can access individual cell from a Formal Table. A sample example code snippet to access and modify Styles of table entry
import mlreportgen.dom.*;
doc = Document('test');
a = magic(5);
table = FormalTable(a);
table.RowSep = 'Solid'
table.ColSep = 'Solid'
table.Border = 'Solid'
table.Body.entry(1,2).Style = {Color('red')} ;
table.Body.entry(1,1).Style = {BackgroundColor('Green')};
append(doc,table);
close(doc);
rptview(doc.OutputPath);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!