How to save Excel file as a variable and pull data from it?

25 ビュー (過去 30 日間)
Din N
Din N 2021 年 7 月 9 日
回答済み: Sergio Yanez-Pagans 2021 年 7 月 9 日
I have an Excel file with several sheets. I would like to first read the whole Excel file and then just pull data from specific sheets. This is what I have now. This works but is very slow and I have to do this for every sheet.
data_prev=readtable('Predictions.xlsx','Sheet','Specific Impulse','Range','A1:A10');
And this is what I would like to do:
k=readtable('Predictions.xlsx');
data_prev(l,etc.)
So, to make it more clear, I just want to read the whole file and store it as a variable ( k for example) and then when I need to read a specific sheet, just use that variable.
I cannot share my Excel file for various reasons, so I am just asking for some guidance.

採用された回答

Walter Roberson
Walter Roberson 2021 年 7 月 9 日
Unfortunately, Mathworks does not provide any method of reading all sheets at the same time.
I am not familiar enough with the Excel object model to know if it is even possible with Excel to fetch data from multiple sheets at the same time.

その他の回答 (1 件)

Sergio Yanez-Pagans
Sergio Yanez-Pagans 2021 年 7 月 9 日
Using the Import Data option in the Home tab of MATLAB might be the easiest thing to you assuming you don't have tons of sheets in your Excel file.

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by