Office.GetSelectedDataOptions interface

提供用于自定义返回的数据及其格式设置方式的选项。

注解

示例

/* Set the selection options. These will:
 - Pass the string "myContext" to the callback.
 - Include both visible and hidden data.
 - Return the formatted values of the selection 
     (for an Excel date, 1/1/2023 instead of 44928).
 */  
const options: Office.GetSelectedDataOptions = {
    asyncContext: "myContext",
    filterType: Office.FilterType.All,
    valueFormat: Office.ValueFormat.Formatted
}

// Get the selected data in the Office document as text.
Office.context.document.getSelectedDataAsync(
    Office.CoercionType.Text,
    options,
    (asyncResult) => {
        if (asyncResult.status === Office.AsyncResultStatus.Failed) {
            console.error(`${asyncResult.asyncContext}: asyncResult.error.message`);
        } else {
            console.log(`The selected data is "${asyncResult.value}".`);
        }
});

属性

asyncContext

在传递给回调的 AsyncResult 对象的 asyncContext 属性中返回的、未更改的任何类型的用户定义的项。

filterType

指定是仅获取可见 (,即筛选) 数据还是所有数据。 筛选数据时很有用。 使用 Office.FilterType 或等效字符串。 在 Word 文档中忽略此参数。

valueFormat

指定是否设置数据格式。 使用 Office.ValueFormat 或等效字符串。

属性详细信息

asyncContext

在传递给回调的 AsyncResult 对象的 asyncContext 属性中返回的、未更改的任何类型的用户定义的项。

asyncContext?: any

属性值

any

filterType

指定是仅获取可见 (,即筛选) 数据还是所有数据。 筛选数据时很有用。 使用 Office.FilterType 或等效字符串。 在 Word 文档中忽略此参数。

filterType?: Office.FilterType | string

属性值

valueFormat

指定是否设置数据格式。 使用 Office.ValueFormat 或等效字符串。

valueFormat?: Office.ValueFormat | string

属性值