How can I speed-up the ''write, read and save'' of an excel file from matlab?
이전 댓글 표시
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');
채택된 답변
추가 답변 (1개)
Image Analyst
2013년 9월 20일
편집: Image Analyst
2013년 9월 23일
1 개 추천
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
ES
2013년 9월 23일
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.
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!