I tried to create a new excel workbook, but it’s doesn’t work. I use Visual Studio 2012 with .Net Freamework 4.5 and Microsoft Office 15.
I was looking at these articles:
http://csharp.net-informations.com/excel/csharp-excel-tutorial.htm
http://www.codeproject.com/Articles/248531/Export-Excel-File-for-Csharp
If I try to create a new ApplicationClass("ApplicationClass xlsApp = new ApplicationClass();"), I get this error:
“Microsoft.Office.Interop.Excel.ApplicationClass’ cannot be embedded.
Use the applicable interface instead.”
I using Microsoft.Office.Interop.Excel.
Do you know the solution? Thank you in advance.
As the error clearly states,
Write
new Application().Even though
Applicationis an interface, the compiler will convert this into the appropriate COM activation code.The error is caused by Embedded PIAs; disabling that (in the reference properties) will also fix it.