How to save uitable() to PNG
Show older comments
I am trying to use uitable() to convert my Table to a PNG, but I'm having trouble saving it.
Using R2018a, no fancy add-ons

t = array2table(zeros(4,1));
t.Properties.VariableNames{'Var1'} = 'id';
t.id(:) = 1;
t.fieldA = {'a'; 'b'; 'c'; 'd'};
t.GroupCount = [22; 1; 19; 0];
f = uifigure;
uit = uitable(f, 'Data', t);
Note that f = figure doesn't work, otherwise it would be easy to save as PNG:
f=figure;
uit = uitable(f, 'Data', t);
Error using uitable
Functionality not supported with figures created with the figure function. For more information, see Graphics Support in App Designer.
Answers (2)
newbie9
on 1 Apr 2020
Swaroop
on 5 Nov 2022
0 votes
There is a better solution now if you are using version 2020b or higher
Instead of figure handle use a uifigure handle. Add all the styling you want and export the uifigure as image or PDF using exportapp(). This method is much more flexible than using a figure handle.
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!