필터 지우기
필터 지우기

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

조회 수: 6 (최근 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
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 CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by