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);
답변 (2개)
David Sanchez
2013년 8월 13일
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')
David Sanchez
2013년 8월 13일
0 개 추천
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
David Sanchez
2013년 8월 13일
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'.
NoYeah
2020년 11월 20일
useless
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!