In excel COM interop (C#), what is the difference between:
_sheet = (Excel._Worksheet)_wb.Worksheets["SheetName"];
and
_sheet = (Excel._Worksheet)_wb.Sheets["SheetName"];
?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With