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

5 ビュー (過去 30 日間)
Collegue
Collegue 2017 年 3 月 28 日
コメント済み: Dipti S 2019 年 3 月 1 日
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);

回答 (1 件)

Nagini Venkata Krishna Kumari Palem
Nagini Venkata Krishna Kumari Palem 2017 年 3 月 30 日
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 件のコメント
Collegue
Collegue 2017 年 6 月 26 日
I can't write num2str(numero) it doesn't function. How can I write the incremental process in another way?
Dipti S
Dipti S 2019 年 3 月 1 日
Try something
Row_Num =1 ;
num2str(Row_Num);

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

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by