In excel COM interop (C#), what is the difference between:
_sheet = (Excel._Worksheet)_wb.Worksheets["SheetName"];
and
_sheet = (Excel._Worksheet)_wb.Sheets["SheetName"];
?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sheets can contain other “Sheets” than Worksheets – Worksheets are not the only possibiliity. E. g. there where Sheets which only contained diagrams, but no Cells. They are not much in use today.
So, to be save it is best to stick to the Worksheets property, because this only gives you worksheets which have a documented format. With bad luck, sheet could contain a Sheet which differs from your expectations.
I doubt that there are many “non-worksheets” left in the wild, but you never know and Microsoft may introduce more sheet-variants.