Effacer les filtres
Effacer les filtres

How to check existence of worksheet in excel file

42 vues (au cours des 30 derniers jours)
YoungKwang
YoungKwang le 11 Jan 2012
Commenté : Ilya Gurin le 13 Août 2021
I'm working on some script and i need to check if there's any particular name of worksheet. Is there anyway to check the workshee existing in excel file? Additionally, I wanna know if there is the way deleting particular worksheet. And I don't wanna use activeX for this. Can anybody help me?

Réponse acceptée

C.J. Harris
C.J. Harris le 11 Jan 2012
[A,B] = xlsfinfo('foofoo.xlsx');
sheetValid = any(strcmp(B, 'foo2'));
  2 commentaires
YoungKwang
YoungKwang le 12 Jan 2012
Oh. Appreciate your answer so much. It did work. !!
Ilya Gurin
Ilya Gurin le 13 Août 2021
Matlab help now says, "xlsfinfo is not recommended. Use sheetnames instead."

Connectez-vous pour commenter.

Plus de réponses (1)

Doug Hull
Doug Hull le 11 Jan 2012
>> [a,b] = xlsread('foofoo.xlsx','foo2')
Error using xlsread>activate_sheet (line 435)
Specified worksheet was not found.
Error in xlsread (line 259)
activate_sheet(Excel,sheet);
Throw a Try Catch around it.
  3 commentaires
Doug Hull
Doug Hull le 11 Jan 2012
I like Chris' answer better about xlsinfo. Mine will error for the wrong sheet and then you can TRY CATCH the error.
YoungKwang
YoungKwang le 12 Jan 2012
I got it solved with Chris's way. But thanks for your answer as well.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by