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 ;-)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by