How to copy and paste several cells from e.g. Excel into a MATLAB uitable?
90 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 23 Jun. 2022
Beantwortet: Jason
am 1 Mär. 2024
We develop a graphical user interface (GUI) with the Matlab App Designer. Many users of the GUI would like to copy the data from Excel with ‘ctrl + c’ and then wants to paste it to the UITable in the app with ‘ctrl + v’. The MATLAB table model (UITable) doesn’t seem to have this feature. Is there any workaround or solution for this problem?
Akzeptierte Antwort
MathWorks Support Team
am 23 Jun. 2022
It is possible to copy and paste single cells from e.g. Excel to MATLAB since MATLAB R2021b. However, it exists an enhancement request to implement a feature to copy and paste several cells to the MATLAB uitable.
In the meantime, you could work around by taking advantage of the following MATLAB File exchange submissions "num2clip: copy numerical arrays to clipboard " and "Straightforward COPY and PASTE functions".
0 Kommentare
Weitere Antworten (1)
Jason
am 1 Mär. 2024
I got this to work:
function TablePasteData(app,src,event,tbl)
%Get Data From Clipboard
clipb=clipboard('paste');
data=[];
newStr = splitlines(clipb);
[n,m]=size(newStr);
for i=1:n-1
B=newStr{i};
C=split(B);
l=numel(C);
data(i,1)=str2double(C{1,1});
data(i,2)=str2double(C{2,1});
if l==3
data(i,3)=str2double(C{3,1});
end
end
data
tbl.Data=data;
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!