Adding data into existing excel sheet from matlab
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rekha
am 3 Mai 2013
Kommentiert: vickey vardwaj
am 19 Aug. 2021
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 Kommentare
syahdan edy murad
am 6 Jul. 2018
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
am 19 Aug. 2021
how can we add a row at 100th row and the old 100th row shifts to 101th row?
Akzeptierte Antwort
Mark Whirdy
am 6 Mai 2013
Bearbeitet: Mark Whirdy
am 6 Mai 2013
It seems that variable "mydata" is of size [1x3] but the size of the range you elected is [1x1] (i.e. a single excel cell rather than a range of cells) in
xlCurrRange = xlsheet.Range(['A' num2str(newRange)]);
% ['A' num2str(newRange)] = 'A301' since newRange appears to be the scalar 1 which is added to 300
I think that instead of 'A301' you want to have 'A301:C301' which is
xlsheet.Range(['A', num2str(newRange),':C', num2str(newRange)]);
which should capture the full [1x3] size of "mydata"
Is this it or have I misunderstood?
Weitere Antworten (1)
Mark Whirdy
am 3 Mai 2013
Bearbeitet: Mark Whirdy
am 3 Mai 2013
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 Kommentare
Adithya Pillai
am 25 Jun. 2020
Hi Rekha Try using a while loop to update the range after writing each row/column into the excel file
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!