How can i store multiple data into same excel file ?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello all,
I am trying to store multiple data from m-file into same excel file.
my program selects a file and displays the corresponding outputs.
After that I am using the following to store into excel data:
%create the cell array containing the column headers
columnHeader = {'plotted points_time','plotted points_voltage', 'surfacearea1','surfacearea2'};
%write the column headers first
xlswrite('C:\Documents and Settings\ototemp-u\Desktop\myfile.xlsx', columnHeader );
%write the data directly underneath the column headers
xlswrite('C:\Documents and Settings\ototemp-u\Desktop\myfile.xlsx', t(record2),'Sheet1','A2');
xlswrite('C:\Documents and Settings\ototemp-u\Desktop\myfile.xlsx',Z2(record2),'Sheet1','B2');
winopen('C:\Documents and Settings\ototemp-u\Desktop\myfile.xlsx')
I want the program to store data from different selected files into 1 excel sheet.
Please help me out.
Regards,
0 commentaires
Réponses (1)
Matt Tearle
le 22 Mar 2011
I'm going to assume that the issue is that you want to run this code again later (with different data), so you don't necessarily know, when you run it that second time, how much data is already in the xls file. In that case, a simple fix is to use exist to see if the xls file already exists. If so, use
[~,~,raw] = xlsread(file);
rowoffset = size(raw,1);
to work out how many rows to skip. (Set rowoffset = 0 is the file doesn't exist.)
Then use num2str to make the Excel cell references for writing. Eg
Cref = ['B',num2str(rowoffset+2)];
xlswrite(...,Cref);
2 commentaires
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!