Try to open my Excel file using C# and get an error

后端 未结 3 1161
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-29 04:42

I try to read my Exel file from code and received System.InvalidCastException:

Additional information: Unable to cast COM object of type \'System.__Co

3条回答
  •  孤街浪徒
    2021-01-29 04:59

    Seems like you are using

        Microsoft.Office.Tools.Excel.Worksheet 
    

    instead of

        Microsoft.Office.Interop.Excel.Worksheet
    

    which is why you are getting an invalid cast exception.

提交回复
热议问题