主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

compiler.package.excelClientForProductionServer

MATLAB Production ServerExcel 客户端创建安装程序

自 R2021b 起

说明

compiler.package.excelClientForProductionServer(results) 使用由 compiler.build.excelClientForProductionServer 函数生成的 compiler.build.Results 对象 results 创建 Excel® 客户端安装程序。

示例

compiler.package.excelClientForProductionServer(results,Name,Value) 使用 compiler.build.Results 对象 results 创建一个安装程序,并使用一个或多个 名称-值参量指定附加选项。

示例

compiler.package.excelClientForProductionServer(results,'Options',opts) 使用 compiler.build.Results 对象 resultsInstallerOptions 对象 opts 指定的安装程序选项创建一个安装程序。如果您使用 InstallerOptions 对象,则不能使用名称-值参量指定任何其他选项。

示例

clientLibrary compiler.package.excelClientForProductionServer(files,clientLibrary,serverArchive)mcccompiler.build.excelClientForProductionServer 命令生成的文件创建安装程序。clientLibrary 是 Excel 客户端库的名称,serverArchive 是部署在生产服务器上的 CTF 文件的名称。

示例

compiler.package.excelClientForProductionServer(files,clientLibrary,serverArchive,Name,Value)mcccompiler.build.excelClientForProductionServer 命令生成的文件创建一个安装程序。可以使用可选的名称-值参量自定义安装程序。

示例

compiler.package.excelClientForProductionServer(files,'Options',opts) 使用 InstallerOptions 对象 opts 指定的安装程序选项为 mcc 命令生成的文件创建安装程序。如果您使用 InstallerOptions 对象,则不能使用名称-值参量指定任何其他选项。

示例

示例

全部折叠

使用 compiler.build.excelClientForProductionServer 函数的结果为 Excel 客户端创建安装程序。

在 MATLAB® 中,定位要作为 MATLAB Production Server™ 的 MATLAB 加载项部署的 Excel 代码。对于此示例,使用 matlabroot\extern\examples\compiler 中的 magicsquare.m 文件编译。

保存文件 magicsquare.m 的路径。

appFile = fullfile(matlabroot,'extern','examples','compiler','magicsquare.m');

使用 compiler.build.productionServerArchive 命令构建生产服务器存档应用程序。

serverBuildResults = compiler.build.productionServerArchive(appFile);

使用 compiler.build.excelClientForProductionServer 为服务器存档构建 Excel 客户端。

clientBuildResults = compiler.build.excelClientForProductionServer(serverBuildResults);

使用 compiler.package.excelClientForProductionServer 函数为 Excel 客户端创建安装程序。

compiler.package.excelClientForProductionServer(clientBuildResults);
该函数在名为 MyAppInstaller 的文件夹中生成一个名为 magicsquareinstaller 的安装程序。

使用 compiler.build.excelClientForProductionServer 函数的结果为 Excel 客户端创建安装程序,并使用名称-值参量对其进行自定义。

保存位于 magicsquare.m 的文件 matlabroot\extern\examples\compiler 的路径。

appFile = fullfile(matlabroot,'extern','examples','compiler','magicsquare.m');

使用 compiler.build.productionServerArchive 命令构建生产服务器存档。

serverBuildResults = compiler.build.productionServerArchive(appFile);

使用 compiler.build.excelClientForProductionServer 为服务器存档构建 Excel 客户端。

clientBuildResults = compiler.build.excelClientForProductionServer(serverBuildResults);

使用 compiler.package.excelClientForProductionServer 函数为 Excel 客户端创建安装程序。使用名称-值参量指定服务器 URL 和安装程序名称。

compiler.package.excelClientForProductionServer(clientBuildResults,...
'ServerURL','https://localhost:9988',...
'InstallerName','MagicSquare_Installer');
该函数在名为 MagicSquare_Installer 的文件夹中生成一个名为 magicsquareinstaller 的安装程序。

使用 compiler.build.excelClientForProductionServer 函数的结果为 Excel 客户端创建安装程序,并使用 InstallerOptions 对象对其进行自定义。

保存位于 magicsquare.m 的文件 matlabroot\extern\examples\compiler 的路径。

appFile = fullfile(matlabroot,'extern','examples','compiler','magicsquare.m');

使用 compiler.build.productionServerArchive 命令构建生产服务器存档应用程序。

serverBuildResults = compiler.build.productionServerArchive(appFile);

使用 compiler.build.excelClientForProductionServer 为服务器存档构建 Excel 客户端。

clientBuildResults = compiler.build.excelClientForProductionServer(serverBuildResults);

创建一个 ExcelClientForProductionServerOptions 对象。使用名称-值参量指定安装程序名称和图标。

opts = compiler.package.ExcelClientForProductionServerOptions(clientBuildResults,...
    'InstallerName','MyClientInstaller')
    'InstallerIcon',which('peppers.png'))
opts = 

  ExcelClientForProductionServerOptions with properties:

      ServerArchive: 'magicsquare.ctf'
      ClientLibrary: 'magicsquare.dll'
      InstallerName: "MyClientInstaller"
      InstallerIcon: 'C:\Program Files\MATLAB\R2025a\toolbox\matlab\imagesci\peppers.png'
    MaxResponseSize: 750
      ServerTimeOut: 60
          ServerURL: ''
     SSLCertificate: ''
            Version: '1.0'
          OutputDir: '.\magicsquareExcelClientInstaller'

您还可以使用点符号修改 ExcelClientForProductionServerOptions 对象的属性。

opts.ServerTimeOut = 40;

使用 compiler.package.excelClientForProductionServer 函数和选项对象为 Excel 客户端创建安装程序。

compiler.package.excelClientForProductionServer(clientBuildResults,...
    opts);

使用 mcc 的输出为 Excel 系统上的 Windows® 客户端创建安装程序。

编写一个生成幻方的 MATLAB 函数。将该函数保存在名为 mymagic.m 的文件中。

function out = mymagic(in)
out = magic(in)

使用 mcc 命令构建生产服务器存档。

mcc -W CTF:mymagic -U -v mymagic.m
includedSupportPackages.txt
mccExcludedFiles.log
mymagic.ctf
readme.txt
requiredMCRProducts.txt
unresolvedSymbols.txt

使用 mcc 命令构建客户端 Excel 加载项。

mcc -W 'mpsxl:mymagic,Class1,version=1.0' -b -v class{Class1:mymagic.m} 
Class1.cs
mymagic.bas
mymagic.dll
mymagic.reg
mymagic.xla
readme.txt

使用 mcc 生成的文件为 Excel 客户端创建安装程序。

compiler.package.excelClientForProductionServer(...
    {'mymagic.dll','mymagic.xla'},...
    'ClientLibrary','mymagic.dll',...
    'ServerArchive','mymagic.ctf')
该函数在名为 ServerArchiveExcelClientInstaller.exe 的文件夹中生成一个名为 ServerArchiveExcelClientInstaller 的安装程序。

使用名称-值参量为 Excel 客户端自定义安装程序。

使用 compiler.build.productionServerArchive 命令构建生产服务器存档。

appFile = fullfile(matlabroot,'extern','examples','compiler','magicsquare.m');
serverBuildResults = compiler.build.productionServerArchive(appFile);

保存生成的 magicsquare.ctf 文件的路径。

serverArchive = fullfile(serverBuildResults.Options.OutputDir,'magicsquare.ctf');

使用 compiler.build.excelClientForProductionServer 为服务器存档构建 Excel 客户端。

clientBuildResults = compiler.build.excelClientForProductionServer(serverBuildResults);

保存生成的 magicsquare.xlamagicsquare.dll 文件的路径。

ExcelAddIn = fullfile(clientBuildResults.Options.OutputDir,'magicsquare.xla');
clientLibrary = fullfile(clientBuildResults.Options.OutputDir,'magicsquare.dll');

使用 compiler.package.excelClientForProductionServer 函数为 Excel 客户端创建安装程序。

compiler.package.excelClientForProductionServer(...
    {clientLibrary,ExcelAddIn},...
    'ClientLibrary',clientLibrary,...
    'ServerArchive',serverArchive,...
    'OutputDir','magicExcelMPSInstaller',...
    'InstallerName','magicInstaller')

使用 InstallerOptions 对象为 Excel 客户端自定义安装程序。

  1. 使用 mcc 命令构建生产服务器存档。

    mcc -W CTF:magicsquare -U -v magicsquare.m
  2. 使用 mcc 命令构建客户端 Excel 加载项。

    mcc -W 'mpsxl:magicsquare,Class1,version=1.0' -b -v class{Class1:magicsquare.m} 
  3. 创建一个 ExcelClientForProductionServerOptions 对象。使用名称-值参量指定安装程序名称和图标。

    opts = compiler.package.ExcelClientForProductionServerOptions(...
        'ClientLibrary','magicsquare.dll',...
        'ServerArchive','magicsquare.ctf',...
        'Version','2.0');

输入参数

全部折叠

Excel 客户端构建结果,指定为 compiler.build.Results 对象。通过保存 compiler.build.excelClientForProductionServer 函数的输出来创建 Results 对象。

要安装的文件和文件夹列表,指定为字符向量单元元胞数组或字符串数组。这些文件通常由 mcc 命令或 compiler.build.excelClientForProductionServer 函数生成,还可以包含安装的加载项运行所需的任何其他文件和文件夹。附加文件与应用程序可执行文件一起安装在安装目录中。

  • 可以使用同一版本的 compiler.package.excelClientForProductionServer 函数打包在特定版本中生成的文件。

  • 只要构建命令和 compiler.package.excelClientForProductionServer 函数来自同一版本,一个操作系统上的 .ctf 类型的文件就可以使用另一个操作系统上的 compiler.package.excelClientForProductionServer 函数进行打包。

示例: {'magic.dll','magic.xla','readme.txt'}

数据类型: string | cell

安装程序选项,指定为 ExcelClientForProductionServerOptions 对象。

Excel 客户端库,指定为字符向量或字符串标量。

示例: 'D:\Documents\MATLAB\work\MagicSquare\magic.dll

数据类型: char | string

生产服务器存档的名称,指定为字符向量或字符串标量。

示例: 'D:\Documents\MATLAB\work\MagicSquare\magic.ctf

数据类型: char | string

名称-值参数

全部折叠

Name1=Value1,...,NameN=ValueN 的形式指定可选参量对组,其中 Name 是参量名称,Value 是对应的值。名称-值参量必须出现在其他参量之后,但对各个参量对组的顺序没有要求。

如果使用的是 R2021a 之前的版本,请使用逗号分隔每个名称和值,并用引号将 Name 引起来。

示例: 'Version','9.5' 指定已安装应用程序的版本。

安装程序文件的名称,指定为字符向量或字符串标量。扩展名由执行该函数的操作系统决定。

示例: 'InstallerName','MagicSquare_Excel_Installer'

用作安装程序图标的图像文件的路径,指定为字符向量或字符串标量。

默认路径为:

'matlabroot\toolbox\compiler\packagingResources\default_icon_48.png'

示例: 'InstallerSplash','D:\Documents\MATLAB\work\images\myicon.png'

保存安装程序的文件夹路径,指定为字符向量或字符串标量。

若未指定路径,则各个操作系统的默认路径为:

操作系统默认安装目录
Windows.\addInNameExcelClientInstaller
Linux®./addInNameExcelClientInstaller
macOS./addInNameExcelClientInstaller

上面列出的目录中的 . 代表当前工作目录。

示例: 'OutputDir','D:\Documents\MATLAB\work\myExcelMPSInstaller'

客户端接受的响应的最大大小,以兆字节 (MB) 为单位

示例: 'MaxResponseSize',420

服务器超时延迟,以秒为单位指定。该值指定客户端在超时之前等待响应的时间。

示例: 'ServerTimeOut',200

MATLAB 生产服务器 URL,指定为字符向量或字符串标量。它必须具有以下格式:

http://path.to.url:port

示例: 'ServerURL','https://localhost:9988'

数据类型: char | string

HTTPS 的自签名证书的路径,指定为字符向量或字符串标量。

示例: 'SSLCertificate','domain.crt'

数据类型: char | string

已安装应用程序的版本号,指定为字符向量或字符串标量。

示例: 'Version','2.0'

数据类型: char | string

版本历史记录

在 R2021b 中推出