Interop type 'Microsoft.Office.Interop.Excel.ApplicationClass' cannot be embedded. Use the applicable interface instead.
In most cases, we are using the Interop Excel class like below.
Excel.ApplicationClass xlapp = new Excel.ApplicationClass();
Here it is enough to say that 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();
Typically, to change your code to use an interface type instead of a class type you just need to remove the 'Class' suffix and compile the code! Another way to find what the applicable interface is - look at the definition of the class type.
Comments
Post a Comment