Excel.NumberFormatInfo class
数値を表示するカルチャに適した形式を定義します。 これは、現在のシステム カルチャ設定に基づいています。
- Extends
注釈
プロパティ
context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
currency |
通貨値の通貨記号を取得します。 これは、現在のシステム設定に基づいています。 |
number |
数値の小数点として使用される文字列を取得します。 これは、現在のシステム設定に基づいています。 |
number |
数値の小数点の左側にある数字のグループを区切るために使用される文字列を取得します。 これは、現在のシステム設定に基づいています。 |
メソッド
load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
toJSON() | API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript |
プロパティの詳細
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
currencySymbol
通貨値の通貨記号を取得します。 これは、現在のシステム設定に基づいています。
readonly currencySymbol: string;
プロパティ値
string
注釈
numberDecimalSeparator
数値の小数点として使用される文字列を取得します。 これは、現在のシステム設定に基づいています。
readonly numberDecimalSeparator: string;
プロパティ値
string
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/culture-info.yaml
// This will convert a number like "14,37" to "14.37"
// (assuming the system decimal separator is ".").
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sample");
const decimalSource = sheet.getRange("B2");
decimalSource.load("values");
context.application.cultureInfo.numberFormat.load("numberDecimalSeparator");
await context.sync();
const systemDecimalSeparator = context.application.cultureInfo.numberFormat.numberDecimalSeparator;
const oldDecimalString: string = decimalSource.values[0][0];
// This assumes the input column is standardized to use "," as the decimal separator.
const newDecimalString = oldDecimalString.replace(",", systemDecimalSeparator);
const resultRange = sheet.getRange("C2");
resultRange.values = [[newDecimalString]];
resultRange.format.autofitColumns();
await context.sync();
});
numberGroupSeparator
数値の小数点の左側にある数字のグループを区切るために使用される文字列を取得します。 これは、現在のシステム設定に基づいています。
readonly numberGroupSeparator: string;
プロパティ値
string
注釈
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/50-workbook/culture-info.yaml
await Excel.run(async (context) => {
// This will convert a number like "123-456-789" to "123,456,789"
// (assuming the system thousands separator is ",").
const sheet = context.workbook.worksheets.getItem("Sample");
const bigNumberSource = sheet.getRange("B3");
bigNumberSource.load("values");
context.application.cultureInfo.numberFormat.load("numberGroupSeparator");
await context.sync();
const systemThousandsSeparator = context.application.cultureInfo.numberFormat.numberGroupSeparator;
const oldBigNumberString: string = bigNumberSource.values[0][0];
// This assumes the input column is standardized to use "-" as the number group separator.
const newBigNumberString = oldBigNumberString.replace(/-/g, systemThousandsSeparator);
const resultRange = sheet.getRange("C3");
resultRange.values = [[newBigNumberString]];
resultRange.format.autofitColumns();
await context.sync();
});
メソッドの詳細
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync()
を呼び出す必要があります。
load(options?: Excel.Interfaces.NumberFormatInfoLoadOptions): Excel.NumberFormatInfo;
パラメーター
読み込むオブジェクトのプロパティのオプションを提供します。
戻り値
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync()
を呼び出す必要があります。
load(propertyNames?: string | string[]): Excel.NumberFormatInfo;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。
戻り値
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync()
を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Excel.NumberFormatInfo;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select
は、読み込むプロパティを指定するコンマ区切り文字列で propertyNamesAndPaths.expand
、読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。
戻り値
toJSON()
API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON()
メソッドを JSON.stringify()
オーバーライドします。 (JSON.stringify
さらに、渡される オブジェクトの メソッドを呼び出 toJSON
します)。元の Excel.NumberFormatInfo オブジェクトは API オブジェクトですが、メソッドは、元の toJSON
オブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト (として Excel.Interfaces.NumberFormatInfoData
型指定) を返します。
toJSON(): Excel.Interfaces.NumberFormatInfoData;
戻り値
Office Add-ins
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示