MATLAB Answers

how to make all cells in uitable editable in matlab GUI and save them when i press pushbutton ? how to read all contents from xlsread array

97 views (last 30 days)
I have GUI which has uitable. I want to read data into table and display when I select options in the listbox ... The GUI also has two push buttons edit and save to enable edit and save after I make changes I am using xlsread to read data into array. however, for some reason, it reads all the cells but not the first two rows of excel file which has text


Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 23 Jun 2018
[~, ~, raw] = xlsread('YourFile.xls');
Now raw will contain headers and all.
h = uitable('data', raw, 'ColumEditable', true(1, size(raw,2)));


Show 2 older comments
Vasishta Bhargava
Vasishta Bhargava on 23 Jun 2018
It outputs the same format as before ... An interesting change I observed is when I place a number in first row and first column it starts to read the all the sheets in cell array, displaying the number of matrix elements in each element of cell array like this instead of sheetname
Columns 1 through 8
{62×55 double} {51×55 double} {60×55 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
Columns 9 through 11
{0×0 double} {0×0 double} {0×0 double}
how can I read them using xlsread now ... when I do that in this format
data= xlsread('file.xlsx',Sheets{1});
it shows error
Sheet argument must be a character vector or an integer.
Vasishta Bhargava
Vasishta Bhargava on 23 Jun 2018
Ok, I got it now ...
but how do I write the data contents to specific cell/s of uitable after I read it using xlsread
Walter Roberson
Walter Roberson on 23 Jun 2018
It is not possible to directly write to specific cells of a uitable. All you can do is create a numeric array (if your data is pure numbers) or cell array (if you have some non-numeric entries) and put things where you want in that array, and then set the resulting array as the Data property of the uipanel.
uitable is not a spreadsheet; you cannot address parts of it, and there are no macros, and it is not very flexible about formatting.

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Translated by