Save a Uitable with coloured cells as as png.

2 vues (au cours des 30 derniers jours)
Alessandro Togni
Alessandro Togni le 28 Avr 2021
Hi, i've created a Uitable object and colured its cells with this code:
app.UITable.Data=CreateUITable(app, app.deltas_table, app.deltas_threshold);
%% GUI TABLE COLOURING (ANALYSIS MODULE)
% Hightlight over-threshold values in red
[redRows, redCols]= find( abs(app.UITable.Data{:,2}) >= app.deltas_threshold);
z = uistyle('BackgroundColor',[1 0.6 0.6]);
addStyle(app.UITable, z ,'cell',[redRows, redCols]);
addStyle(app.UITable, z ,'cell',[redRows, redCols+1]);
addStyle(app.UITable, z ,'cell',[redRows, redCols+2]);
addStyle(app.UITable, z ,'cell',[redRows, redCols+3]);
% Hightlight under-threshold values in green
[greenRows, greenCols]= find( abs(app.UITable.Data{:,2}) <= app.deltas_threshold);
n = uistyle('BackgroundColor',[0.6 1 0.6]);
addStyle(app.UITable, n ,'cell', [greenRows, greenCols]);
addStyle(app.UITable, n ,'cell',[greenRows, greenCols+1]);
addStyle(app.UITable, n ,'cell',[greenRows, greenCols+2]);
addStyle(app.UITable, n ,'cell',[greenRows, greenCols+3]);
% Hightlight NaN values in gray
NaNidxs = ismissing(app.UITable.Data);
[NaNrow,NaNcol] = find(NaNidxs);
s = uistyle('BackgroundColor',1/255*[200,200,200]);
addStyle(app.UITable,s,'cell',[NaNrow, NaNcol]);
addStyle(app.UITable,s,'cell',[NaNrow, NaNcol+1]);
addStyle(app.UITable,s,'cell',[NaNrow, NaNcol+2]);
addStyle(app.UITable,s,'cell',[NaNrow, NaNcol+3]);
Now i want to save the table on a .png (or pdf) file.
Any help would be really appreciated.
Alessandro

Réponses (1)

Adam Danz
Adam Danz le 28 Avr 2021
One solution is to put the uitable within a uipanel and then use exportgraphics to export the table.
If you want to export the entire figure you don't need to embed the table within a panel.

Catégories

En savoir plus sur Printing and Saving dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by