efficient way of importing excel sheet

1 次查看(过去 30 天)
dharmin
dharmin 2022-12-8
评论: Rik 2022-12-9
%Hello everyone,
%I am trying to read excel data which contains multiple sheets. Is there any more efficient way of writing this code?
[filename,pathname,~]=uigetfile('*.xlsx','*.xlsx'); %select the excel file
fullname = fullfile(pathname,filename);
sheets = sheetnames(fullname);
[~,~,raw] = xlsread([fullname],sheets(2)); % taking sheets(2) because it contains the main data.
%is there any way to create multiple tables and the number of tables will be equal to the number of sheets.
  1 个评论
Rik
Rik 2022-12-9
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.

请先登录,再进行评论。

回答(1 个)

Jonas
Jonas 2022-12-8
编辑:Jonas 2022-12-8
if you activate MultiSelect in uigetfile, you can select more than one file. The resulting variables are then cell arrays with the file/folder names. You can then use a for loop if you like
even more efficient would be using dir() to get the file names etc, then you dont need to klick ;-)

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by