C# -Excel interoperability

后端 未结 6 2085
广开言路
广开言路 2021-02-04 00:36

I want to call Excel Sheet from C# 4.0 (VS 2010 Express Edition) .

When i declare ,

Microsoft.Office.Interop.Excel.ApplicationClass excel =
    new Micro         


        
相关标签:
6条回答
  • 2021-02-04 00:53

    For MS Office 2016 you need to use the following no dramas

    Excel.Application oExcel = new Excel.Application();
    
    0 讨论(0)
  • 2021-02-04 01:05

    Solved:

    Excel.ApplicationClass derives from Excel.Application interface and one can even instantiate Excel using Excel.Application interface. Rewriting this code as below produces exact same results:

    Excel.Application xlapp = new Excel.Application();
    
    0 讨论(0)
  • 2021-02-04 01:06

    The answer for me was to mark Embed Interop types as false. See this question.

    0 讨论(0)
  • 2021-02-04 01:08

    Here is a blog post that deals with that. Looks like you need to change

    Microsoft.Office.Interop.Excel.ApplicationClass();
    

    to

    Microsoft.Office.Interop.Excel.Application();
    
    0 讨论(0)
  • 2021-02-04 01:08
    Excel.Application = new Excel.ApplicationClass();
    

    Note the leading Excel.Application, not Excel.ApplicationClass.

    Also note, this is straight out of the MSDN page for ApplicationClass.

    0 讨论(0)
  • 2021-02-04 01:10

    You need to declare the variable as Microsoft.Office.Interop.Excel.Application, but instantiate it as Microsoft.Office.Interop.Excel.ApplicationClass.

    0 讨论(0)
提交回复
热议问题