Bonjour à tous,
je cherche a ouvrir les header d'un fichier excel dans un listbox.
Lorsque j'ouvre un fichier, j'aimerais que la liste se mette à jour en ajoutant les nouveau header à la suite.
Voici le code que j'utilise :
Pour info ma listbox s'appelle tri
lorsque j'ouvre par exemple le même fichier deux foix j'ai le message d'erreur suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 function open_dinon_Callback(hObject, eventdata, handles) [filename, pathname] = uigetfile( ... {'*.csv', 'All flight data (*.csv)'; ... }, ... 'SELECT DATA FROM DINON'); % If "Cancel" is selected then return if isequal([filename,pathname],[0,0]) return % Otherwise construct the fullfilename and Check and load the file. else File = fullfile(pathname,filename); set(handles.adress_dinon,'string',filename) end %lecture du fichier et stockage de variable dans la figure [num,text,raw] = xlsread(File) handles.dinon.text=text handles.dinon.raw=raw guidata(gcf,handles) %enregistrement de dinon oldlist={get(handles.tri,'string')} if isempty(oldlist{:}) set(handles.tri,'string',handles.dinon.text(1,:)) else set(handles.tri,'string',{oldlist{:},handles.dinon.text{1,:}}) end
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 oldlist = {28x1 cell} ??? Error using ==> set Cell array of strings may only contain string and numeric matrices. Error in ==> Data_management>open_dinon_Callback at 327 set(handles.tri,'string',{oldlist{:},text{:}}) Error in ==> gui_mainfcn at 95 feval(varargin{:}); Error in ==> Data_management at 42 gui_mainfcn(gui_State, varargin{:});
Merci de votre aide
Partager