Adding data into existing excel sheet from matlab
이전 댓글 표시
I have an excel sheet 'myvalues.xlsx' cosisting of 200 vectors of 127bits each. Now I want to add another vector to my excel sheet which will be placed as the 201th row without changing the existing data. How can I acheive it. Have tried xlswrite but its not working.
댓글 수: 2
syahdan edy murad
2018년 7월 6일
i have the same problem here, could you include your code ? like saving the excel file, and adding it after you execute the file again.
vickey vardwaj
2021년 8월 19일
how can we add a row at 100th row and the old 100th row shifts to 101th row?
채택된 답변
추가 답변 (1개)
Mark Whirdy
2013년 5월 3일
편집: Mark Whirdy
2013년 5월 3일
Hi Rekha
Lots of similar questions on the Matlab Answers here if you search.
Here's one of mine on using the activex server to manipulate excel range values from matlab. In general there's no reason to use xlsread or xlswrite
Use commands like:
mydata = rand(100,3);
xlCurrRange = xlActiveSheet.Range('A201:C300');
xlCurrRange.Value2 = mydata;
google "actxserver" - no shortage of other examples on the web
Alternatively, have a look at Alec de Zegher's approach
All the best
Mark
댓글 수: 4
Rekha
2013년 5월 3일
Mark Whirdy
2013년 5월 4일
편집: Mark Whirdy
2013년 5월 4일
Hi Rekha
From my understanding of your original question, the crux of the issue is that you want to add write a vector to an excel-sheet beginning at row 201. If the crux of the problem is more the "vector-comparison" algorithm, then I need a lot more detail than the above. But it seems you have a handle on this already.
If the problem is in fact writing to excel (regardless of the content of "sparseVector"), it is easier at my end to ignore the context-specific details and just talk about writing to excel. Could you try the below code [which writes a matrix to Range('A201:C300')] & tell me which part does not work or any part you have a question about?
try
xlApp = actxGetRunningServer('Excel.Application'); % capture existing excel application
catch ME %#ok
xlApp = actxserver('Excel.Application'); % instantiate new excel application
end
xlApp.Visible = 1;
xlWorkbook = xlApp.ActiveWorkbook;
xlActiveSheet = xlWorkbook.ActiveSheet;
xlCurrRange = xlActiveSheet.Range('A201:C300'); %
mydata = randn(100,3);
xlCurrRange.Value2 = mydata;
Rekha
2013년 5월 5일
Adithya Pillai
2020년 6월 25일
Hi Rekha Try using a while loop to update the range after writing each row/column into the excel file
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!