Save a Uitable with coloured cells as as png.

2 次查看(过去 30 天)
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

回答(1 个)

Adam Danz
Adam Danz 2021-4-28
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.

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by