How can I speed-up the ''write, read and save'' of an excel file from matlab?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I want to write on an excel file, run a VBA macro, save the excel file and finally read from the file, several times. I used below code, but it is very time-consuming. The question is how can I speed up the above commands? xlswrite usually takes: 11 sec., open: 1 sec., Run: 10 sec., save: 20 sec. and xlsread: 2 sec. It should be mentioned that I don't need to save the file but if I don't save, the command xlsread doesn't read the newly-changed cells values!
xlswrite ('C:\test.xls',M ,'sheet_name_1','T10:T16');
excelObject = actxserver('Excel.Application');
excelObject.Workbooks.Open('C:\test.xls');
excelObject.Run('VBAMacro');
excelObject.WorkBooks.Item('test.xls').Save;
excelObject.WorkBooks.Item('test.xls').Close;
CC = xlsread ('C:\test.xls','sheet_name_2','E:E');
0 Kommentare
Akzeptierte Antwort
ES
am 20 Sep. 2013
use ActiveX to write and read instead of xlswrite and xlsread respectively.
0 Kommentare
Weitere Antworten (1)
Image Analyst
am 20 Sep. 2013
Bearbeitet: Image Analyst
am 23 Sep. 2013
I don't understand what you're doing. You either use xlsread() and xlswrite(), OR use ActiveX, not both. After you did the xlswrite there was no need to write it again using ActiveX. For speed when you need to open, transfer data, and save multiple times you should be using ActiveX, not xlsread() and xlswrite(). See attached demo.
1 Kommentar
ES
am 23 Sep. 2013
Cant Agree more. Use of (xlsread, xlswrite) and (ActiveX) methods should be exclusive of each other. I would recommend use of (xlsread, xlswrite) in cases were there is little data to read and write. For large data, formatting and so on, ActiveX is ideal. Using both approaches together is not recommended.
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!