Office.AddBindingFromPromptOptions interface

提供用于配置提示和标识创建的绑定的选项。

注解

使用方

示例

// Add a binding to the document by prompting the user to select a cell in the document.
function addBinding() {
    const bindings = Office.context.document.bindings;
    const options: Office.AddBindingFromPromptOptions = { 
        id: "prompt-binding",
        promptText: "Select a cell" 
    };
    const callback = (asyncResult: Office.AsyncResult<Office.Binding>) => {
        if (asyncResult.status === Office.AsyncResultStatus.Failed) {
            console.error(asyncResult.error.message);
            return;
        }

        console.log(`Created binding "${asyncResult.value.id}" of type "${asyncResult.value.type}".`);
    };

    bindings.addFromPromptAsync(Office.BindingType.Text, options, callback);
}

属性

asyncContext

在传递到回调的 AsyncResult 对象的 asyncContext 属性中返回的任何类型的用户定义项,保持不变。

id

绑定的唯一 ID。 如果未提供,则自动生成。

promptText

指定显示在提示 UI 中且告诉用户选择内容的字符串。 限制为 200 个字符。 如果未传递 promptText 参数,则显示“请进行选择”。

sampleData

Specifies a table of sample data displayed in the prompt UI as an example of the kinds of fields (columns) that can be bound by your add-in. TableData 对象中提供的标头指定字段选择 UI 中使用的标签。

注意:此参数仅用于 Access 的加载项。 It is ignored if provided when calling the method in an add-in for Excel.

属性详细信息

asyncContext

在传递到回调的 AsyncResult 对象的 asyncContext 属性中返回的任何类型的用户定义项,保持不变。

asyncContext?: any

属性值

any

id

绑定的唯一 ID。 如果未提供,则自动生成。

id?: string

属性值

string

promptText

指定显示在提示 UI 中且告诉用户选择内容的字符串。 限制为 200 个字符。 如果未传递 promptText 参数,则显示“请进行选择”。

promptText?: string

属性值

string

sampleData

警告

现已弃用此 API。

Microsoft Access is no longer supported.

Specifies a table of sample data displayed in the prompt UI as an example of the kinds of fields (columns) that can be bound by your add-in. TableData 对象中提供的标头指定字段选择 UI 中使用的标签。

注意:此参数仅用于 Access 的加载项。 It is ignored if provided when calling the method in an add-in for Excel.

sampleData?: Office.TableData

属性值