How can I add a row and continue writing in the same Excell with matlab interface?
9 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
回答(1 个)
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,
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!