Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to copy and past Excel-data into a MATLAB GUI table?

2,037 views
Skip to first unread message

Sebastian Gatzka

unread,
Nov 19, 2012, 3:49:13 AM11/19/12
to
Hello world,

i really would like to paste rows and columns from Excel into a MATLAB GUI table.
So far, if I past into the table all the data is crammed into the one cell which is currently highlighted.
Thats not what I want, but to preserve the rows and columns from Excel.

Any ideas how this can be managed?

Thanks in advance!
Sebastian

Ryan

unread,
Nov 25, 2012, 9:43:09 AM11/25/12
to
I just stumbled across this post. I wonder why no one has offered a suggestion yet. Well, nevertheless, here's my recommendation. please read this:
http://www.mathworks.com/help/matlab/ref/xlsread.html

That is probably the single best comprehensive resource for integrating Matlab and Excel. Here is a single line of code that will import excel data into Matlab:
[num,txt,raw] = xlsread('C:\Program Files\MATLAB\R2012a\Symbols.xls')

Just change the path to your own Excel file.

"Sebastian Gatzka" <sebastian.g...@gmx.de> wrote in message <k8crq9$g3f$1...@newscl01ah.mathworks.com>...

Sebastian Gatzka

unread,
Nov 25, 2012, 7:27:09 PM11/25/12
to
Thank you Ryan,

but I don't want to work with files, I need a copy & past function.

"Ryan" wrote in message <k8tapt$m4t$1...@newscl01ah.mathworks.com>...

Sumit Tripathi

unread,
Jan 7, 2013, 9:09:09 PM1/7/13
to
Following code would work for you. I tested it with GUIDE. I just created a pushbutton with following callback fuction. The callback would paste the data into the table with tag 'uitable1'.

import = importdata('-pastespecial');
%% Convert Nx1 cell array into NxM cell array. The delimiter in each row is TAB character %ASCII value 9
import1={};
for i=1:length(import(:,1))
TAB_char=regexpi(import{i},char(9));%find tabs
temp={import{i}(1:TAB_char(1))};
for comma_i=2:length(TAB_char)
temp=[temp,{import{i}(TAB_char(comma_i-1):TAB_char(comma_i))}];
end
temp=[temp,{import{i}(TAB_char(end):end)}];
import1=[import1;temp];
end
set(handles.uitable1,'Data',import1);


"Sebastian Gatzka" <sebastian.g...@gmx.de> wrote in message <k8crq9$g3f$1...@newscl01ah.mathworks.com>...

Flavio Prattico

unread,
Feb 26, 2014, 5:15:16 AM2/26/14
to
"Sebastian Gatzka" <sebastian.g...@gmx.de> wrote in message <k8crq9$g3f$1...@newscl01ah.mathworks.com>...
Hi Sebastian,
I answer to your post many time later but now I'm working with a similar problem and still today there are no solution on internet.

My solution is the follow:

function copyExcel_callback(hO, ev, handles)
str = clipboard('paste');
str = strrep(str,',','.');
import=str2num(str);
set(t1, 'Data', import);
end

this is the function of a push button that paste into the table named t1 what is copied in the clipboard. This code include also the solution of the problem that in excel the decimal is marked with the comma.

Bye Flavio

Kyle

unread,
Apr 1, 2014, 9:22:08 AM4/1/14
to
"Flavio Prattico" <flaviop...@gmail.com> wrote in message <lekerk$ai9$1...@newscl01ah.mathworks.com>...
Hi Flavio,

I was having similar problems that made it difficult to use uitable without have to do a ton of different cases for each type of data that I wanted to copy and paste. This File Exchange submission seems to solve a lot of those problems and is easy to use:

http://www.mathworks.com/matlabcentral/fileexchange/28016-straightforward-copy-and-paste-functions

Good Luck,
Kyle

Anna

unread,
Sep 9, 2014, 2:29:06 PM9/9/14
to
Hello,

For me, the following shortcut worked: I copied a column from the MATLAB GUI table, and then asked Excel to reproduce the format. Then copypaste started working.

Anna



"Sebastian Gatzka" <sebastian.g...@gmx.de> wrote in message <k8crq9$g3f$1...@newscl01ah.mathworks.com>...
0 new messages