Filter löschen
Filter löschen

Read Excel sheet (one after other )

2 Ansichten (letzte 30 Tage)
b.m.n n
b.m.n n am 26 Nov. 2016
Kommentiert: CA am 28 Feb. 2019
hello... i have 15 Excel sheet in one file .. i want put them in loop to read in matlap How can i do that? thankyou..

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 26 Nov. 2016
The second output of xlsinfo can tell you the names of all of the sheets. You can then loop over them with xlsread
filename = 'YourInputFile.xls';
[~, sheets] = xlsinfo(filename);
num_sheets = length(sheets);
data = cell(num_sheets, 1);
for K = 1 : num_sheets
data{K} = xlsread(filename, sheets{K});
end
  2 Kommentare
b.m.n n
b.m.n n am 27 Nov. 2016
Bearbeitet: b.m.n n am 27 Nov. 2016
thank you so much
CA
CA am 28 Feb. 2019
Hi,
Would this also work if I have a script that I need to run on multiple sheets within the same excel file?
So I would need it to run my whole script for sheet 1, then run my whole script for sheet 2, then for sheet 3 and so on....
If so, would it be a case of doing something like this?... Or would it be something completly different?
filename = 'YourInputFile.xls';
[~, sheets] = xlsinfo(filename);
num_sheets = length(sheets);
data = cell(num_sheets, 1);
for K = 1 : num_sheets
data{K} = xlsread(filename, sheets{K});
% % INSERT MY SCRIPT HERE % %
end

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by