フィルターのクリア

paste data in uitable one col at a time

7 ビュー (過去 30 日間)
Nuno
Nuno 2011 年 11 月 9 日
Hi,
I managed to paste data from excel into matlab uitable thanks to Roland's solution in KeyPressFcn. Here is how i do it:
import = importdata('-pastespecial');
set(handles.uitable1,'Data',import);
But this only works if i copy all data from excel at same time.
What I want is to be able to paste one column at a time from different excel files without overwriting the already pasted data on uitable and without having the work of pasting all data to a temporary excel file and then to the uitable... any assistance will be appreciated
Thanks

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 11 月 9 日
It can be done. But you've known that when you set the data of the uitable, you have to set the whole table data, not just a particular column.
So, in your function, you'll have to read in the uitable data first, and then set a particular column, and then write the data back.
data=get(handles.uitable1,'Data');
data(:,3)=importdata('-pastespecial');
set(handles.uitable1,'Data',data);
A couple of things:
  1. You need to make sure the size and format (cell array or data array) match
  2. You probably need to decide which column to write based on the current selected cell in the uitable.
  2 件のコメント
Nuno
Nuno 2011 年 11 月 9 日
The problem is that when you paste into a specific column (in this case col 3) the uitable replaces previous data (columns 1 and 2) with zeros.
if there was a way to append data instead of replacing...
Fangjun Jiang
Fangjun Jiang 2011 年 11 月 17 日
Then read the old table data, read the data from clipboard and do the insertion.
OldData=magic(5);
PasteData=rand(5,1);
NewData=[OldData(:,1:2),PasteData,OldData(:,3:5)]

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by