Get selected range in Excel file using MATLAB

Hello,
I have seen a MATLAB GUI program that is able to open the Excel file and get the range of the cells that the user have selected. This value is returned to MATLAB.
I have no idea how it is possible since the Excel file is normal without any macro. Additionally, when MATLAB opens an Excel file, it does not run anymore so how possible can we obtain anything from Excel ?
Thank you very much in advance.

 採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 9 月 9 日

0 投票

The function is probably uiimport. Type uiimport in Command Window to start.
You can also use xlsread(). Type help xlsread to find out.

4 件のコメント

Christophe
Christophe 2011 年 9 月 9 日
Thank you for your answer.
I tried with uiimport, I can select the desired range of the Excel file but when I click "Done", it takes the whole matrix and not the selected range only.
Using xlsread, I can read the file and select the desired range if I input the range data but I would like to able to select the range directly on the Excel file (or a wizard) using the mouse.
Christophe
Christophe 2011 年 9 月 9 日
Sorry, I checked the xlsread function again and it seems that putting the flag to -1, gives the possibility to do so.
Thank you for your help.
Fangjun Jiang
Fangjun Jiang 2011 年 9 月 9 日
That's true. You could open the .xls file outside of MATLAB, select the data and copy it (press Ctrl+C), then at the first dialog of uiimport, Select "Clipboard" instead of "File". I just did it and it works.
Christophe
Christophe 2011 年 9 月 9 日
Thank you very much. It works too but I think the xlsread method is more natural for users.
Anyway I did not know the existence of uiimport, it may help me in the future.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by