The current topic describes, how you can use other applications, like for example Microsoft Excel in your EPLAN API add-in.
If you want to access data of an other program, the application needs to have a suitable interface. Because an EPLAN add-in is written in managed code (C# or VB.NET), you need to be able to set a reference to the other program. Either the other application already exposes its interface as .NET assembly, or the .NET Framework creates an interop assembly from a COM type library.
The following example shows the use of Microsoft Excel 2003. Excel exposes its functions as COM interface. In your EPLAN add-in, you can add a reference to the registered type library of Excel:
After you added the reference, the development environment creates an interop assembly. The types of this assembly then can be used in managed code (C#, etc.):
In your application code, the use of Excel would look like in the following example:
Excel is started as a separate process. The only object, you create with new is the Excel.ApplicationClass. All other objects like Excel.Workbook, are created – or queried from Excel – through functions of the Application object.
Each call of Excel functions is a communication between processes!