Office.ValueFormat enum
Указывает, форматируются ли значения, такие как числа и даты, возвращаемые вызванным методом.
Комментарии
Например, если параметр valueFormat указан как formatted, в приложении Office будет сохранено форматирование числа в виде валюты или даты, отформатированного в виде мм/дд/гг в приложении Office. Если для параметра 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 | Возвращаются неформатированные данные. |