Effacer les filtres
Effacer les filtres

How can I add a row and continue writing in the same Excell with matlab interface?

6 vues (au cours des 30 derniers jours)
Collegue
Collegue le 28 Mar 2017
Commenté : Dipti S le 1 Mar 2019
I have this code and I need to update patients information to the excel but, I want to have an excel with different patients information. So, I need an excel for example like this:
Maria gutierrez 752896 24/05/2017 Fernando Ortega 587458 48/02/2017
This is my code for the excel: function Guardar_Callback(hObject, eventdata, handles) global numero
numero=0; numero=numero+1; data.nombre=get(handles.edit1,'String'); data.apellido=get(handles.edit2,'String'); data.registro=get(handles.edit3,'String'); data.fecha=get(handles.dateEditBoxHandle,'String');
fid=fopen('DATA.txt','w+'); xlswrite('D:\interfaz\dd.xls',{numero,data.nombre,data.apellido,data.registro,data.fecha},'Hoja1','A2'); xlswrite('D:\interfaz\dd.xls',{'Nº','Nombre','Apellido','Registro','Fecha'} ,'Hoja1','A1');
fclose(fid);

Réponses (1)

Nagini Venkata Krishna Kumari Palem
From an initial review of your code, I understand that you already added column headers and one row of values. Now, you wish to add more rows to the same excel sheet.
You can add a new row by incrementing the 'xlrange' value i.e., A3, A4, A5 and so on. For example,
xlswrite(filename, {data1,data2,...,dataN}, 'Sheet1', 'A3');
xlswrite(filename, {data1,data2,...,dataN}, 'Sheet1', 'A4');
xlswrite(filename, {data1,data2,...,dataN}, 'Sheet1', 'A5');
If you want to automate the incremental process, you can do as follows,
xlswrite(filename, {data1,data2,...,dataN}, 'Sheet1', ['A' num2str(numero)]);
Following documentations are more helpful,
  2 commentaires
Collegue
Collegue le 26 Juin 2017
I can't write num2str(numero) it doesn't function. How can I write the incremental process in another way?
Dipti S
Dipti S le 1 Mar 2019
Try something
Row_Num =1 ;
num2str(Row_Num);

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by