Create and Install Deployable Archive with Excel Integration for MATLAB Production Server
Supported Platform: Microsoft® Windows® only.
This example shows how to create a deployable archive with Excel® integration using a MATLAB® function. You can then deploy the generated archive on MATLAB Production Server™.
Prerequisites
MATLAB Compiler SDK™ requires .NET framework 4.0 or later to build Excel add-ins for MATLAB Production Server.
To generate the Excel add-in file (.xla), enable Trust access to the VBA project
                object model in Excel. If you do not do this, you can manually create the add-in by importing
            the .bas file into Excel.
Create Function in MATLAB
In MATLAB, examine the MATLAB program that you want to package.
For this example, write a function mymagic.m as follows.
function y = mymagic(x)
y = magic(x);At the MATLAB command prompt, enter mymagic(3) to check your
            function's output.
 ans =
     8     1     6
     3     5     7
     4     9     2Create Deployable Archive with Excel Integration Using                 compiler.build.excelClientForProductionServer
Create a deployable archive with Excel integration using a programmatic approach.
- Create a production server archive using - mymagic.mand save the build results to a- compiler.build.Resultsobject.- buildResults = compiler.build.productionServerArchive('mymagic.m');
- Build the deployable archive with Excel integration using the - compiler.build.excelClientForProductionServerfunction.- mpsxlResults = compiler.build.excelClientForProductionServer(buildResults, ... 'Verbose','on'); - You can specify additional options in the - compiler.buildcommand by using name-value arguments. For details, see- compiler.build.excelClientForProductionServer(MATLAB Compiler SDK).- The - compiler.build.Resultsobject- buildResultscontains information on the build type, generated files, included support packages, and build options.- The function generates the following files within a folder named - mymagicexcelClientForProductionServerin your current working directory:- includedSupportPackages.txt— Text file that lists all support files included in the assembly.
- mymagic.bas— VBA module file that can be imported into a VBA project.
- mymagic.dll— Dynamic library required by the Excel add-in.
- mymagic.reg— Text file that contains information on unresolved symbols.
- mymagic.xla— Excel add-in that can be installed directly in Excel.
- mymagicClass.cs— Text file that contains information on unresolved symbols.
- mccExcludedFiles.log— Log file that contains a list of any toolbox functions that were not included in the application. For information on non-supported functions, see MATLAB Compiler Limitations (MATLAB Compiler).
- readme.txt— Text file that contains packaging and deployment information.
- requiredMCRProducts.txt— Text file that contains product IDs of products required by MATLAB Runtime to run the application.
 - Note - The generated Excel add-in does not include MATLAB Runtime or an installer. To create an installer using the - buildResultsobject, see- compiler.package.excelClientForProductionServer(MATLAB Compiler SDK).
Create Deployable Archive with Excel Integration Using mcc
As an alternative to
                compiler.build.excelClientForProductionServer, you can also use
            the mcc function to create a deployable archive by running the
            following commands.
- mcc -W CTF:mymagic -U -d '[Target server directory]' -v [directory containing mymagic.m] 
- mcc -W 'mpsxl:mymagic,Class1,version=1.0' -b -d '[Target client directory]' -v [Location of mymagic.m] class{Class1:[location of mymagic.m]}- Note - The generated Excel add-in does not include MATLAB Runtime or an installer. To create an installer, see - compiler.package.excelClientForProductionServer(MATLAB Compiler SDK).
Install Deployable Archive with Excel Integration on Server
You must deploy the archive to a MATLAB Production Server instance before you can use the add-in in Excel.
To install the deployable archive on a server instance:
- Locate the deployable archive (CTF file), which is in the - mymagicproductionServerArchivefolder if you used the- compiler.build.productionServerArchivefunction. If you used- mcc, the file is in your working folder.- For this example, the file name is - mymagic.ctf.
- Copy the archive file to the - auto_deployfolder of the server instance. The server instance automatically deploys it and makes it available to interested clients.
Install the Excel Add-In on Client
- If you used the - compiler.build.productionServerArchivefunction, run- compiler.package.excelClientForProductionServer(MATLAB Compiler SDK) on the result to generate the installer, which is in the- mymagicinstallerfolder. Here, it is named- MyAppInstaller.exe.
- Open the installer and follow the directions. - The files installed on the client include: - mymagic.bas
- mymagic.dll
- mymagic.xla
- readme.txt
- ServerConfig.dll
 
See Also
compiler.package.excelClientForProductionServer (MATLAB Compiler SDK) | mcc (MATLAB Compiler)