Count worksheets in an excel workbook without using xlsfinfo

조회 수: 12 (최근 30일)
Michael Horn
Michael Horn 2021년 4월 23일
답변: Harsh 2021년 4월 26일
I have excel workbooks with multiple worksheets that I want to read in.
Is there a function besides xlsfinfo that will count the number of worksheets?
I can explain why xlsfinfo doesn't work, if anyone needs to know, but it is beside the point. The short answer is that it returns a character variable if it encounters an issue inspecting the workbook. The same issue creates no problem for readtable. So I can get my data, but I need to find a way of telling my loop how many worksheets to look for.
Thanks

채택된 답변

Harsh
Harsh 2021년 4월 26일
You can use sheetnames.
>> sheets = sheetnames('patients.xls')
sheets =
3×1 string array
"Sheet1"
"Sheet2"
"Sheet3"
>> numel(sheets)
ans =
3

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by