Main Content

Create and Install a Deployable Archive withExcelIntegration forMATLABProduction 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 onMATLAB Production Server™.

Prerequisites

MATLAB Compiler SDK™requires .NET framework 4.0 or later to build Excel add-ins forMATLAB Production Server.

To generate the Excel add-in file (.xla), enableTrust access to the VBA project object modelin Excel. If you do not do this, you can manually create the add-in by importing the.basfile into Excel.

Create Function inMATLAB

In MATLAB, examine the MATLAB program that you want to package.

For this example, write a functionmymagic.mas follows.

functiony = mymagic(x) y = magic(x);

At the MATLAB command prompt, entermymagic(3).

The output is:

ans = 8 1 6 3 5 7 4 9 2

Create Deployable Archive withExcelIntegration Using Production Server Compiler App

Package the function into a deployable archive with Excel integration using the Production Server Compiler app. Alternatively, if you want to create a deployable archive from the MATLAB command window using a programmatic approach, seeCreate Deployable Archive with Excel Integration Using compiler.build.excelClientForProductionServer.

  1. To open theProduction Server Compilerapp, typeproductionServerCompilerat the MATLAB prompt.

    Alternatively, on theMATLAB Apps选项卡,最右边的Appssection, click the arrow. InApplication Deployment, clickProduction Server Compiler. In theProduction Server Compilerproject window, clickDeployable Archive with Excel integration.

  2. In theProduction Server Compilerproject window, specify the main file of the MATLAB application that you want to deploy.

    1. In theExported Functionssection, click.

    2. In theAdd Fileswindow, browse to the example folder, and select the function you want to package.

      ClickOpen.

    Doing so adds the functionmymagic.mto the list of main files.

    Screen shot of Production Server Compiler app top navigation pane.

Customize the Application and Its Appearance

Customize your deployable archive with Excel integration and add more information about the application.

  • Archive information— Editable information about the deployed archive with Excel integration.

  • Client configuration——Configure theMATLAB Production Serverclient. Select theDefault Server URL, decide wait time-out, and maximum size of response for the client, and provide an optional self-signed certificate forhttps.

  • Additional files required for your archive to run— Additional files required by the generated archive to run. These files are included in the generated archive installer. SeeManage Required Files in Compiler Project.

  • Files installed with your archive— Files that are installed with your archive on the client and server. The files installed on the server include:

    • Generated deployable archive (CTF file)

    • Generatedreadme.txt

    The files installed on the client include:

    • mymagic.bas

    • mymagic.dll

    • mymagic.xla

    • readme.txt

    • ServerConfig.dll

    SeeSpecify Files to Install with Application.

  • Options— The optionRegister the resulting component for you only on the development machineexclusively registers the packaged component for one user on the development machine.

Archive information, client configuration, files installed with your archive sections of the Production Server Compiler app.

Package the Application

  1. To generate the packaged application, clickPackage.

    In the Save Project dialog box, specify the location to save the project.

    Package doialog box.

  2. In thePackagedialog box, verify thatOpen output folder when process completesis selected.

    当部署过程完成, examine the generated output.

    • for_redistribution— Folder containing the installer to distribute the archive on theMATLAB Production Serverclient and server

    • for_redistribution_files_only— Folder containing the files required for redistributing the application on theMATLAB Production Serverclient and server

    • for_testing— Folder containing the raw generated files to create the installer

    • PackagingLog.html— Log file generated byMATLAB Compiler SDK

Create Deployable Archive withExcelIntegration Usingcompiler.build.excelClientForProductionServer

As an alternative to theProduction Server Compilerapp, you can create a deployable archive with Excel integration using a programmatic approach.

  1. Create a production server archive usingmymagic.mand save the build results to acompiler.build.Resultsobject.

    buildResults = compiler.build.productionServerArchive('mymagic.m');
  2. Build the deployable archive with Excel integration using thecompiler.build.excelClientForProductionServerfunction.

    mpsxlResults = compiler.build.excelClientForProductionServer(buildResults,...'Verbose','on');

    You can specify additional options in thecompiler.buildcommand by using name-value arguments. For details, seecompiler.build.excelClientForProductionServer.

    Thecompiler.build.ResultsobjectbuildResultscontains information on the build type, generated files, included support packages, and build options.

    The function generates the following files within a folder namedmymagicexcelClientForProductionServerin 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, seeMATLAB Compiler Limitations.

    • readme.txt— Text file that contains packaging and deployment information.

    • requiredMCRProducts.txt— Text file that contains product IDs of products required byMATLAB Runtimeto run the application.

    Note

    The generated Excel add-in does not includeMATLAB Runtimeor an installer. To create an installer using thebuildResultsobject, seecompiler.package.installer.

Install the Deployable Archive withExcelIntegration

You must deploy the archive to aMATLAB Production Serverinstance before you can use the add-in in Excel.

To install the deployable archive on a server instance:

  1. Locate the archive in thefor_redistribution_files_only\server\folder if you used the Production Server Compiler, or theaddmatrixproductionServerArchivefolder if you used thecompiler.build.productionServerArchivefunction.

    For this example, the file name ismymagic.ctf.

  2. Copy the archive file to theauto_deployfolder of the server instance. The server instance automatically deploys it and makes it available to interested clients.

For more information, seeMATLAB Production Serverdocumentation.

See Also