Conditional formatting for MATLAB Report Generator Table

10 Ansichten (letzte 30 Tage)
Dinesh Nandlal
Dinesh Nandlal am 27 Okt. 2016
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?

Antworten (1)

Krishnan Ramkumar
Krishnan Ramkumar am 8 Dez. 2016
Bearbeitet: Krishnan Ramkumar am 8 Dez. 2016
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);

Kategorien

Mehr zu MATLAB Report Generator finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by