Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.Office.Interop.Excel.ApplicationClass has no constructor defined

Tags:

I tried to follow How to open an Excel file in C# tutorial, i.e. added a reference on the Com tab to Microsoft Office 14.0 Object Library and tried to compile code:

using Excel = Microsoft.Office.Interop.Excel; //... Excel.Application xlApp; Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet;  xlApp = new Excel.ApplicationClass();//error here //... 

and faced a compile-time error, saying

There is no constructor defined for Microsoft.Office.Interop.Excel.ApplicationClass type.

What am I missing?

like image 902
horgh Avatar asked Dec 24 '12 01:12

horgh


2 Answers

Try this:

Excel._Application xlApp = new Excel.Application(); 
like image 149
Vlad Spreys Avatar answered Sep 20 '22 15:09

Vlad Spreys


Use the following to open it:

xlApp = CreateObject("Excel.Application"); 

CreateObject creates and returns a reference to a COM object. Documentation may be found here:

http://msdn.microsoft.com/en-us/library/7t9k08y5%28v=vs.71%29.aspx

like image 28
PeterJ Avatar answered Sep 18 '22 15:09

PeterJ