How to check existence of worksheet in excel file
42 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
YoungKwang
il 11 Gen 2012
Commentato: Ilya Gurin
il 13 Ago 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?
0 Commenti
Risposta accettata
C.J. Harris
il 11 Gen 2012
[A,B] = xlsfinfo('foofoo.xlsx');
sheetValid = any(strcmp(B, 'foo2'));
Più risposte (1)
Doug Hull
il 11 Gen 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 Commenti
Doug Hull
il 11 Gen 2012
I like Chris' answer better about xlsinfo. Mine will error for the wrong sheet and then you can TRY CATCH the error.
Vedere anche
Categorie
Scopri di più su Data Import from MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!