主要内容

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

compiler.build.excelClientForProductionServer

Microsoft Production Server 创建 MATLABExcel 加载项

自 R2021b 起

说明

小心

该函数仅支持 Windows® 操作系统。

compiler.build.excelClientForProductionServer(Results) 使用由 compiler.build.productionServerArchive 函数创建的 compiler.build.Results 对象 ResultsMATLAB® Production Server™ 创建一个 Excel® 加载项。在创建 Excel 加载项之前,请安装支持的编译器

示例

compiler.build.excelClientForProductionServer(FunctionFiles,ServerArchive) 使用 FunctionFiles 指定的 Excel 函数和 ServerArchive 指定的 MATLAB Production Server 存档创建一个 MATLAB 加载项。

示例

compiler.build.excelClientForProductionServer(FunctionFiles,ServerArchive,Name,Value) 使用一个或多个名称-值参量指定选项来创建一个 Excel 加载项。选项包括加载项名称、输出目录以及如何处理 Excel 日期数据类型。

示例

compiler.build.excelClientForProductionServer(opts) 使用 compiler.build.ExcelClientForProductionServerOptions 对象 opts 指定选项创建一个 Excel 加载项。不能使用名称-值参量指定任何其他选项。

示例

results = compiler.build.excelClientForProductionServer(___) 使用以上语法中的任意输入参量组合以 compiler.build.Results 对象形式返回编译信息。编译信息包括编译类型、编译文件的路径以及编译选项。

示例

示例

全部折叠

使用 compiler.build.productionServerArchive 函数的结果在 Excel 系统上为 MATLAB Production Server 创建 Windows 加载项。

确保已安装以下软件:

在 MATLAB 中,定位要部署为 MATLAB 加载项的 Excel 函数。对于此示例,使用 matlabroot\extern\examples\compiler 中的文件 magicsquare.m

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

使用 compiler.build.productionServerArchive 命令构建 MATLAB Production Server 存档。将输出保存为 compiler.build.Results 对象 serverBuildResults

serverBuildResults = compiler.build.productionServerArchive(appFile);

使用 compiler.build.excelClientForProductionServer 命令为 MATLAB Production Server 存档构建一个 Excel 加载项。

excelBuildResults = compiler.build.excelClientForProductionServer(serverBuildResults);

该函数会在当前工作目录中名为 magicsquareexcelClientForProductionServer 的文件夹中生成以下文件:

  • includedSupportPackages.txt

  • magicsquare.bas(仅当您启用 'GenerateVisualBasicFile' 选项时)

  • magicsquare.dll

  • magicsquare.reg

  • magicsquare.xla(仅当您启用 'GenerateVisualBasicFile' 选项时)

  • magicsquareClass.cs

  • readme.txt

  • requiredMCRProducts.txt

使用 Excel 函数文件和 MATLAB MATLABProduction Server 存档在 Windows 系统上为 MATLAB MATLAB Production Server 创建 MATLAB 加载项。

使用 MATLAB 函数文件创建 MATLAB Production Server 存档。对于此示例,使用位于 magicsquare.m 中的文件 matlabroot\extern\examples\compiler 作为 compiler.build.productionServerArchive 函数的输入。

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

该函数在 magicsquare.ctf 文件夹中生成文件 magicsquareproductionServerArchive

使用 compiler.build.excelClientForProductionServer 命令为 MATLAB Production Server 存档构建一个 Excel 加载项。指定函数文件和 CTF 文件作为输入。

excelBuildResults = compiler.build.excelClientForProductionServer(mpsFile,'magicsquareproductionServerArchive\magicsquare.ctf');

创建一个 Excel 加载项并使用名称-值参量对其进行自定义。

使用 MATLAB 函数文件创建 MATLAB Production Server 存档。对于此示例,使用位于 magicsquare.m 中的文件 matlabroot\extern\examples\compiler 作为 compiler.build.productionServerArchive 函数的输入。

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

使用 compiler.build.excelClientForProductionServer 命令为 MATLAB Production Server 构建 Excel 加载项。使用名称-值参量指定加载项名称,生成 Microsoft® Visual Basic® 文件并启用详尽输出。

compiler.build.excelClientForProductionServer(mpsFile,...
    'magicsquareproductionServerArchive\magicsquare.ctf',...
    'AddInName','MyMagicSquare',...
    'GenerateVisualBasicFile','on',...
    'Verbose','on');

该函数会在当前工作目录中名为 MyMagicSquareexcelClientForProductionServer 的文件夹中生成以下文件:

  • includedSupportPackages.txt

  • MyMagicSquare.bas

  • MyMagicSquare.dll

  • MyMagicSquare.reg

  • MyMagicSquare.xla

  • MyMagicSquareClass.cs

  • readme.txt

  • requiredMCRProducts.txt

使用 compiler.build.ExcelClientForProductionServerOptions 对象在 Excel 系统上为 MATLAB Production Server 创建 Windows 加载项。

使用 MATLAB 函数文件创建 MATLAB Production Server 存档。对于此示例,使用位于 magicsquare.m 中的文件 matlabroot\extern\examples\compiler 作为 compiler.build.productionServerArchive 函数的输入。

mpsFile = which('magicsquare.m');
compiler.build.productionServerArchive(mpsFile);

使用位于 magicsquare.m 的文件 matlabroot\extern\examples\compiler 创建 ExcelClientForProductionServerOptions 对象。使用名称-值参量指定一个公共输出目录,生成一个 Visual Basic 文件,并启用详尽输出。

appFile = which('magicsquare.m');
opts = compiler.build.ExcelClientForProductionServerOptions(appFile, ...
'magicsquareproductionServerArchive\magicsquare.ctf', ...
'OutputDir','D:\Documents\MATLAB\work\MPSExcelAddIn', ...
'GenerateVisualBasicFile','on','Verbose','on')
opts = 

  ExcelClientForProductionServerOptions with properties:

                         AddInName: 'houdini'
                      AddInVersion: '1.0.0.0'
                         ClassName: 'houdiniClass'
                        DebugBuild: off
                     FunctionFiles: {'C:\Program Files\MATLAB\R2025a\extern\examples\compiler\houdini.m'}
           GenerateVisualBasicFile: on
                     ServerArchive: 'magicsquareproductionServerArchive\magicsquare.ctf'
          ReplaceExcelBlankWithNaN: off
          ConvertExcelDateToString: off
           ReplaceNaNToZeroInExcel: off
    ConvertNumericOutToDateInExcel: off
                           Verbose: on
                         OutputDir: 'D:\Documents\MATLAB\work\MPSExcelAddIn'

使用 ExcelAddInOptions 对象构建加载项。

compiler.build.excelClientForProductionServer(opts);

MATLAB Production Server 创建一个 Excel 加载项,并将有关构建类型、生成的文件、包含的支持包和构建选项的信息保存到 compiler.build.Results 对象中。

使用文件 magicsquare.m 构建 MATLAB Production Server 存档。将输出保存为 compiler.build.Results 对象 serverBuildResults

serverBuildResults = compiler.build.productionServerArchive('magicsquare.m');

使用 serverBuildResults 对象构建 Excel 加载项。

results = compiler.build.excelClientForProductionServer(serverBuildResults)
results = 

  Results with properties:

              BuildType: 'excelClientForProductionServer'
                  Files: {1×1 cell}
IncludedSupportPackages: {}
                Options: [1×1 compiler.build.ExcelClientForProductionServerOptions]
    RuntimeDependencies: [1×1 compiler.runtime.Dependencies]

Files 属性包含以下已编译文件的路径:

  • magicsquare.dll

  • magicsquare.bas

  • magicsquare.xla

注意

仅当您在 compiler.build.excelClientForProductionServer 命令中启用 magicsquare.bas 选项时,文件 magicsquare.xlaFiles 才会包含在 'GenerateVisualBasicFile' 中。

输入参数

全部折叠

实现 MATLAB 函数的文件,指定为字符向量、字符串标量、字符串数组或字符向量元胞数组。文件路径可以是相对于当前工作目录的路径,也可以是绝对路径。文件必须具有 .m 扩展名。

示例: ["myfunc1.m","myfunc2.m"]

数据类型: char | string | cell

Excel 加载项构建选项,指定为 compiler.build.ExcelClientForProductionServerOptions 对象。

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

部署在生产服务器上的 MATLAB Production Server 存档,指定为字符向量或字符串标量。

示例: 'mpsArchive.ctf'

数据类型: char | string

名称-值参数

全部折叠

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

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

示例: 'Verbose','on'

Excel 加载项的名称,指定为字符向量或字符串标量。生成的加载项的默认名称是 FunctionFiles 参量的第一个条目。名称必须以字母开头,并且只能包含字母字符和下划线。

示例: 'AddInName','myAddIn'

数据类型: char | string

加载项版本,指定为字符向量或字符串标量。

示例: 'AddInVersion','4.0'

数据类型: char | string

生成的类的名称,指定为字符向量或字符串标量。如果使用 ClassMap 输入,则无法指定此选项。类别名称必须符合 Excel 类别名称要求。

默认值是追加有 ClassAddInName 参量。

示例: 'ClassName','MagicSquareClass'

数据类型: char | string

将 Excel 日期转换为字符串的标志,指定为 'on''off',或者指定为数字或逻辑值 1 (true) 或 0 (false)。值 'on' 等效于 true,值 'off' 等效于 false。因此,可以将此属性的值用作逻辑值。该值存储为 matlab.lang.OnOffSwitchState 类型的 on/off 逻辑值。

  • 如果将此属性设置为 'on',则编译器会将 Excel 日期数据类型转换为 MATLAB 字符串。

  • 如果将此属性设置为 'off',则不会转换日期。

示例: 'ConvertExcelDateToString','On'

数据类型: logical

将数字数据转换为 Excel 日期的标志,指定为 'on''off',或者指定为数字或逻辑值 1 (true) 或 0 (false)。值 'on' 等效于 true,值 'off' 等效于 false。因此,可以将此属性的值用作逻辑值。该值存储为 matlab.lang.OnOffSwitchState 类型的 on/off 逻辑值。

  • 如果将此属性设置为 'on',则编译器会将数字数据转换为 Excel 日期数据类型。

  • 如果将此属性设置为 'off',则不会转换数字数据。

示例: 'ConvertNumericOutToDateInExcel','On'

数据类型: logical

启用调试符号的标志,指定为 'on''off',或者指定为数值或逻辑值 1 (true) 或 0 (false)。值 'on' 等效于 true,值 'off' 等效于 false。因此,可以将此属性的值用作逻辑值。该值存储为 matlab.lang.OnOffSwitchState 类型的 on/off 逻辑值。

  • 如果将此属性设置为 'on',则加载项将使用调试符号进行编译。

  • 如果将此属性设置为 'off',则加载项不会使用调试符号进行编译。

示例: 'DebugSymbols','On'

数据类型: logical

用于生成 Visual Basic 文件 (.bas) 和 Excel 加载项文件 (.xla) 的标志,指定为 'on''off',或者指定为数值或逻辑值 1 (true) 或 0 (false)。值 'on' 等效于 true,值 'off' 等效于 false。因此,可以将此属性的值用作逻辑值。该值存储为 matlab.lang.OnOffSwitchState 类型的 on/off 逻辑值。

  • 如果将此属性设置为 'on',则该函数将生成一个 Excel 加载项 XLA 文件和一个 Visual Basic BAS 文件,其中包含加载项的 Microsoft Excel 公式函数接口。

  • 如果将此属性设置为 'off',则该函数不会生成 Visual Basic 文件或 Excel 加载项文件。

示例: 'GenerateVisualBasicFile','On'

数据类型: logical

保存编译文件的输出目录的路径,指定为字符向量或字符串标量。该路径可以是相对于当前工作目录的路径,也可以是绝对路径。

构建文件夹的默认名称是加载项名称加上 excelAddIn

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

数据类型: char | string

将空白 Excel 元胞转换为 NaN 的标志,指定为 'on''off',或者指定为数字或逻辑值 1 (true) 或 0 (false)。值 'on' 等效于 true,值 'off' 等效于 false。因此,可以将此属性的值用作逻辑值。该值存储为 matlab.lang.OnOffSwitchState 类型的 on/off 逻辑值。

  • 如果将此属性设置为 'on',则编译器会在编译工件中将空白 Excel 元胞转换为 NaN。

  • 如果将此属性设置为 'off',则不会转换空白 Excel 元胞。

示例: 'ReplaceExcelBlankWithNaN','On'

数据类型: logical

将 NaN 条目转换为零的标志,指定为 'on''off',或者指定为数字或逻辑值 1 (true) 或 0 (false)。值 'on' 等效于 true,值 'off' 等效于 false。因此,可以将此属性的值用作逻辑值。该值存储为 matlab.lang.OnOffSwitchState 类型的 on/off 逻辑值。

  • 如果将此属性设置为 'on',则编译器会将编译工件中的 NaN 条目转换为 Excel 中的零。

  • 如果将此属性设置为 'off',则不会转换 NaN 条目。

示例: 'ReplaceNaNToZeroInExcel','On'

数据类型: logical

控制编译详细程度的标志,指定为 'on''off',或者指定为数值或逻辑 1 (true) 或 0 (false)。值 'on' 等效于 true,值 'off' 等效于 false。因此,可以将此属性的值用作逻辑值。该值存储为 matlab.lang.OnOffSwitchState 类型的 on/off 逻辑值。

  • 如果将此属性设置为 'on',则 MATLAB 命令行窗口会显示进度信息,指示编译过程期间的编译器输出。

  • 如果将此属性设置为 'off',则命令行窗口不会显示进度信息。

示例: 'Verbose','On'

数据类型: logical

输出参量

全部折叠

编译结果,以 compiler.build.Results 对象形式返回。Results 对象包含:

  • 构建类型,即 'excelClientForProductionServer'

  • 以下文件的路径:

    • AddInName.dll

    • AddInName.bas(如果启用 'GenerateVisualBasicFile' 选项)

    • AddInName.xla(如果启用 'GenerateVisualBasicFile' 选项)

  • 包含的支持包的列表

  • 构建选项,指定为 ExcelClientForProductionServerOptions 对象

  • 必需和可选依赖项的列表,指定为 Dependencies 对象

限制

版本历史记录

在 R2021b 中推出