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
For MS Office 2016 you need to use the following no dramas
Excel.Application oExcel = new Excel.Application();
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();
The answer for me was to mark Embed Interop types as false. See this question.
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();
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.
You need to declare the variable as Microsoft.Office.Interop.Excel.Application
, but instantiate it as Microsoft.Office.Interop.Excel.ApplicationClass
.