how to save in specific row and column with this code in excel?

hi..below code is to fetch files and append in separate excel file..i done..but existing is getting saved from A1(first row),but i need to write my data's from 3rd,(starts form C1)..I couldnt bring it..help with this code..
pathName = 'F:\test folder\run\';
fileList = dir(fullfile(pathName, '*.run'));
out = fopen(fullfile(pathName, 'append.xlsx'), 'w');
for k = 1:numel(fileList)
s = fileread(fullfile(pathName, fileList(k).name));
fwrite(out, s,'char');
end
fclose(out);

Antworten (2)

To write in a precise cell within a xls file, use the built-in function xlswrite, which gives that feature.
Example from documentation:
Write mixed text and numeric data to testdata2.xls, starting at cell E1 of Sheet1:
d = {'Time','Temperature'; 12,98; 13,99; 14,97};
xlswrite('testdata2.xls', d, 1, 'E1')

1 Kommentar

I AGREE...but my question is..need to store without overwriting.. i tested with 3 .run files(input).i need to append it one by one...if i use xlswrite..its overwriting..only last file data's alone getting saved. below are my values in each file
file01.run: SAMPLE_20120807_1806 0 +1.122117E+1 +7.190077E+0 +1.460343E+1 file02.run: SAMPLE_20120807_1816 0 +1.122317E+1 +7.150077E+0 +1.460983E+1 file03.run: SAMPLE_20120807_1826 0 +1.132117E+1 +7.190077E+0 +1.430343E+1
i need to append this to single excel file from A3(ROW).IS IT POSSIBLE?

Melden Sie sich an, um zu kommentieren.

David Sanchez
David Sanchez am 13 Aug. 2013

0 Stimmen

Instead of writing values one at a time on each iteration, you should better save the values in an array and then write the whole array into the *.xls file. It's much faster than writing to the .xls on each iteration.

3 Kommentare

sandy
sandy am 13 Aug. 2013
Bearbeitet: sandy am 13 Aug. 2013
thanks david..any faster function or code to save as array in a loop.can you suggest by looking my above code?
From your code, it is not easy to see what your variable(s) will be. I would go to
doc xlswrite
to see the full documentation and some examples. I am sure you will adapt them to your needs.
My example:
y = zeros(3); % initialization of final matrix
for k=1:3
x=rand(3,1); % array random numbers
y(:,k) = x; % copy previous array to kth column of the matrix
end
xlswrite('my_xls.xls',y,'B2'); % write the matrix to xls file, starting in cell 'B2'.
useless

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 13 Aug. 2013

Kommentiert:

am 20 Nov. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by