Main Content

How Excel Add-In Compilation Works

With MATLAB® Compiler™, you create deployable add-ins that run in Microsoft® Excel® applications from MATLAB code. To convert MATLAB functions for use in an Excel add-in, you use the Library Compiler app, the compiler.build.excelAddIn function, or the mcc function.

When you compile your MATLAB code, MATLAB Compiler generates two primary artifacts, a COM component (.dll) and a VBA module (.bas), which it then integrates into a Microsoft Excel add-in (.xla).

To support integration with Microsoft Excel, MATLAB Compiler builds each Excel add-in as a COM object based on the component object model, a Microsoft binary standard for object interoperability. COM components use a common integration architecture that provides a consistent model across multiple applications, including Microsoft Office applications.

To integrate the COM component with your application, you access the COM object from Microsoft Excel through Microsoft Visual Basic® for Applications (VBA). The COM object exposes a single class to the Visual Basic programming environment. This class provides the interface to the MATLAB functions in the form of methods, which correspond to the original MATLAB functions that you include in your project. The VBA module contains simple call wrappers, each implemented as a function procedure for each method of the class.

Related Topics