actxserver excel application

11 views (last 30 days)
Richard
Richard on 2 Dec 2011
Edited: Walter Roberson on 23 May 2022
Can anyone give me a simple explanation of how to use actxserver to import data from matlab. I have a working code by using loops and xlsread but the running time is way too long. All I understand about actxserver is that it will save time as it doesn't open and close excel every time it goes through the loop.
I've got this far:
hExcel = actxserver('Excel.Application');
hExcel.visible = 1; % If you want Excel visible.
hExcel.DisplayAlerts = false; % Avoid excel warning popups
Which basically just opens excel. I now need to get some data...

Accepted Answer

Jan
Jan on 2 Dec 2011
  4 Comments
Fangjun Jiang
Fangjun Jiang on 2 Dec 2011
Yes, to loop through different files, it's better to provide the full path of the files.
To read all the data in the sheet without specifying the range, use
MyRange=Sheet.UsedRange;
MyData=MyRange.Value;

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!