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 | 書式設定されていないデータを返します。 |