Excel.LinkedEntityDataDomainCreateOptions interface

表示用于创建 LinkedEntityDataDomain 要添加到 LinkedEntityDataDomainCollection的对象的选项。

注解

API 集:ExcelApi 1.19

Excel Web 版不支持此界面。

使用方

示例

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-linked-entities.yaml

// Register the product, category, and supplier data sources with Excel.
await Excel.run(async (context) => {
    const domains: Excel.LinkedEntityDataDomainCollection = context.workbook.linkedEntityDataDomains;
    const refreshModes: Excel.LinkedEntityDataDomainRefreshMode[] = [
        Excel.LinkedEntityDataDomainRefreshMode.manual,
        Excel.LinkedEntityDataDomainRefreshMode.onLoad,
        Excel.LinkedEntityDataDomainRefreshMode.periodic
    ];
    // Script Lab prefixes the function ID with the companion sample's name, without spaces.
    const loadFunctionId = "LINKEDENTITYLOADSERVICE.CONTOSOLOADSERVICE";
    const options: Excel.LinkedEntityDataDomainCreateOptions[] = [
        {
            dataProvider: "Contoso",
            id: "products",
            name: "Products",
            loadFunctionId,
            periodicRefreshInterval: 300,
            supportedRefreshModes: refreshModes
        },
        {
            dataProvider: "Contoso",
            id: "categories",
            name: "Categories",
            loadFunctionId,
            periodicRefreshInterval: 300,
            supportedRefreshModes: refreshModes
        },
        {
            dataProvider: "Contoso",
            id: "suppliers",
            name: "Suppliers",
            loadFunctionId
        }
    ];

    // Replace only this sample's domains so registration is repeatable.
    const existingDomains: Excel.LinkedEntityDataDomain[] = options.map((options) =>
        domains.getItemOrNullObject(options.id)
    );
    await context.sync();
    existingDomains.forEach((domain) => {
        if (!domain.isNullObject) {
            domain.delete();
        }
    });
    options.forEach((options) => domains.add(options));
    await context.sync();
    console.log("Registered Products, Categories, and Suppliers. Manual refresh is the default.");
});

属性

dataProvider

指定链接实体数据域的数据提供程序的名称。

id

指定链接实体数据域的 ID。 此 ID 在此 Office 加载项定义的所有链接实体数据域中必须唯一。

loadFunctionId

指定将按需调用的自定义函数的 ID 以解析或刷新 LinkedEntityCellValue 此链接实体数据域的对象。 有关详细信息,请参阅 为自定义函数自动生成 JSON 元数据:ID。

name

指定链接实体数据域的名称。 此名称在此 Office 加载项定义的所有链接实体数据域中必须唯一。

periodicRefreshInterval

指定自动刷新此链接实体数据域的对象的频率(以秒 LinkedEntityCellValue 为单位)。 最小有效值为 300。 如果数组包含值“Periodic”,则 supportedRefreshModes 需要此属性。 仅当链接实体数据域的设置为 refreshMode “定期”时,此属性才适用。

supportedRefreshModes

指定链接实体数据域支持的所有刷新模式。 默认值为 ["Manual"],即使未指定,也始终受支持。 在下次打开工作簿时,将作为链接实体数据域的默认刷新模式加载工作簿中保存的刷新模式。 如果刷新模式未保存在工作簿中,则数组中的第一个值设置为链接实体数据域的默认刷新模式。 如果数组的值为“Periodic”,则还必须为链接的实体数据域设置该 periodicRefreshInterval 属性。

属性详细信息

dataProvider

指定链接实体数据域的数据提供程序的名称。

dataProvider: string;

属性值

string

注解

API 集:ExcelApi 1.19

Excel web 版不支持此属性。

id

指定链接实体数据域的 ID。 此 ID 在此 Office 加载项定义的所有链接实体数据域中必须唯一。

id: string;

属性值

string

注解

API 集:ExcelApi 1.19

Excel web 版不支持此属性。

loadFunctionId

指定将按需调用的自定义函数的 ID 以解析或刷新 LinkedEntityCellValue 此链接实体数据域的对象。 有关详细信息,请参阅 为自定义函数自动生成 JSON 元数据:ID。

loadFunctionId: string;

属性值

string

注解

API 集:ExcelApi 1.19

Excel web 版不支持此属性。

name

指定链接实体数据域的名称。 此名称在此 Office 加载项定义的所有链接实体数据域中必须唯一。

name: string;

属性值

string

注解

API 集:ExcelApi 1.19

Excel web 版不支持此属性。

periodicRefreshInterval

指定自动刷新此链接实体数据域的对象的频率(以秒 LinkedEntityCellValue 为单位)。 最小有效值为 300。 如果数组包含值“Periodic”,则 supportedRefreshModes 需要此属性。 仅当链接实体数据域的设置为 refreshMode “定期”时,此属性才适用。

periodicRefreshInterval?: number;

属性值

number

注解

API 集:ExcelApi 1.19

Excel web 版不支持此属性。

supportedRefreshModes

指定链接实体数据域支持的所有刷新模式。 默认值为 ["Manual"],即使未指定,也始终受支持。 在下次打开工作簿时,将作为链接实体数据域的默认刷新模式加载工作簿中保存的刷新模式。 如果刷新模式未保存在工作簿中,则数组中的第一个值设置为链接实体数据域的默认刷新模式。 如果数组的值为“Periodic”,则还必须为链接的实体数据域设置该 periodicRefreshInterval 属性。

supportedRefreshModes?: Excel.LinkedEntityDataDomainRefreshMode[];

属性值

注解

API 集:ExcelApi 1.19

Excel web 版不支持此属性。