Office.ValueFormat enum
指定由调用方法返回的值(如数字和日期)返回时应用了其格式设置。
注解
例如,如果将 valueFormat 参数指定为“formatted”,则 Office 应用程序中格式设置为货币的数字或格式为 mm/dd/yy 的日期将保留其格式。 如果将 valueFormat 参数指定为 "unformatted",将以其基础顺序序列号形式返回数据。
示例
/* 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}".`);
}
});
字段
| Formatted | 返回格式化的数据。 |
| Unformatted | 返回无格式化的数据。 |