How can I open a generic (not defined) EXCEL file ?

Hello,
the procedure to access a spreadsheet data from MATLAB running an Excel application in an Automation server is well known and explained at the matlab documentation. At the Matlab documentation can be seen something like this:
exl = actxserver('excel.application');
exlWkbk = exl.Workbooks;
exlFile = exlWkbk.Open([docroot '/techdoc/matlab_external/examples/input_resp_data.xls']);
I am writing a code at GUIDe and I haven't found the code to load a generic excel file at a programm function ( something like winopen(cd) at the Command Window). There are other matlab functions like uiopen('-file'), but they dont load the file. Open does also not work because the file in that case has to be defined by the programmer. I need the file to be choosed by the end user.
Thank you.

 Accepted Answer

Is this what you want to do? Have user select an excel file, and then open the excel file with MS Office, or whatever application is set to open this file?
[FileName, FilePath] = uigetfile('*.xls*', 'Open Excel File');
winopen(fullfile(FilePath, FileName));

4 Comments

Not really... I'm working with something like this:
https://de.mathworks.com/help/matlab/matlab_external/example-reading-excel-spreadsheet-data.html
If you see the example, they open a fixed file and then they can read the information from the excel file to matlab. I need to do the same but without the need to specify the name of the file.
Are you referring to this example where they open a fixed file?
exlWkbk = exl.Workbooks;
exlFile = exlWkbk.Open([docroot '/techdoc/matlab_external/examples/input_resp_data.xls']);
And you want to do the same "without the need to specify the name of the file" as in this?
[FileName, FilePath] = uigetfile('*.xls*', 'Open Excel File');
exlFile = exlWkbk.Open(fullfile(FilePath, FileName)); %Open excel file chosen by user
Exactly! It worked. Thank you very much!!!

Sign in to comment.

More Answers (0)

Asked:

on 21 Jun 2018

Commented:

on 22 Jun 2018

Community Treasure Hunt

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

Start Hunting!