How to get the name of a specified excel sheet?

Hello, Is there any way I could get the name of of a specified excel sheet? For example, sheet=2; When I use xlsfinfo, sheet names will be displayed but not in the order of occurrence in an excel file. I appreciate your help.
Thank you

6 Kommentare

Guillaume
Guillaume am 4 Mai 2018
Can you attach a workbook for which xlsfinfo does not return the sheet names in the order they are in the workbook?
Elaheh
Elaheh am 4 Mai 2018
Here you are. I even copy and paste the sheets in the order I wanted in a new excel file and saved it but no difference.
Thank you
>> [~, sheets] = xlsfinfo('5.xls')
sheets =
1×5 cell array
{'Sheet1'} {'2_6'} {'2_7'} {'1_3'} {'1_5'}
matches the order of the sheets in the spreadsheet.
matlab R2017b, excel 2016.
Using your file, I also faced the same problem with xlsfinfo(). Opening with Excel gave warning about a mismatch between file format and extension. Saving a new copy of the file using save as solved the problem for me.
Elaheh
Elaheh am 4 Mai 2018
I had to change the extension because I was not allowed to attach 5 with the extension xlsx.
thank you.
Guillaume
Guillaume am 6 Mai 2018
So, what output do you get? And which version of matlab and which version of excel?
Note that matlab simply asks excel for the list of worksheets, so whatever order you get is the one returned by excel.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Pruthvi G
Pruthvi G am 13 Apr. 2020

0 Stimmen

%%********************************************************************************
% Name : xl_xlsfinfo
% Author : Pruthvi Raj G
% Version : Version 1.0 - 2011b Compactible
% Description : Finds all the sheets in the Excel file (.xls,.xlsm,.xlsx)
% Input : File_Name with path included.
% Date : 11-Feb-2020
%
% Examples : xl_xlsfinfo('D:\Pruthvi\Test_file.xls')
%*********************************************************************************
Use the Below Lines of Code ::
sheets = xl_xlsfinfo('D:\Pruthvi\Test_file.xls')
sheets =
1×5 cell array
{'Sheet1'} {'Sheet2'} {'Sheet3'} {'Sample'} {'Data'}

Gefragt:

am 4 Mai 2018

Kommentiert:

am 13 Apr. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by