How to find next empty row in Excel Worksheet?
이전 댓글 표시
Hi,
I am trying to write a matlab code which allows data to be implemented into an Excel spreadsheet at the next available row.
Currently I have been using the code below which allows me to input data to excel cells that i specify. In the long run i want matlab to automatically find the next available row and implement data into columns of that row. I dont really know how to do this and am fairly new to Matlab so would appreciate any help. (the code below is a very simple version of what I am trying to do)
Fx = 10
Fy = 20
Fz = 30
filename = 'filtereddata.xlsx';
xlswrite(filename,Fx,'Sheet1','A1')
xlswrite(filename,Fy,'Sheet1','B1')
xlswrite(filename,Fz,'Sheet1','C1')
댓글 수: 4
Bob Thompson
2019년 4월 15일
Calling xlswrite for each line of a matrix is horribly inefficient, and it is generally practiced to minimize the number of times you have to call xlswrite or xlsread. It is sometime unavoidable to call these commands multiple times in a script, but people do like to avoid doing so if possible.
All that leads me to these questions: Why are you trying to write multiple sets of data to a spreadsheet individually? Is it not possible to write one large matrix?
jazim sohail
2019년 4월 15일
Bob Thompson
2019년 4월 15일
A simple way of doing this would be to read the data that is in the excel sheet and then simply adjust the write dimensions to be past that. This can be a bit of a memory hog, but if you are only reading and writing once you should be ok.
[~ ~ complete] = xlsread('myspreadsheet.xlsx');
lr = size(complete,1);
range = ['A',num2str(lr+1)];
xlswrite('myspreadsheet.xlsx',mydata,range);
jazim sohail
2019년 4월 15일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!