Excel.NumberFormatInfo class

数値を表示するカルチャに適した形式を定義します。 これは、現在のシステム カルチャ設定に基づいています。

Extends

注釈

[ API セット: ExcelApi 1.11 ]

プロパティ

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

numberDecimalSeparator

数値の小数点として使用される文字列を取得します。 これは、現在のシステム設定に基づいています。

numberGroupSeparator

数値の小数点の左側にある数字のグループを区切るために使用される文字列を取得します。 これは、現在のシステム設定に基づいています。

メソッド

load(options)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNames)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

load(propertyNamesAndPaths)

オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。

toJSON()

API オブジェクトがJSON.stringify()に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (JSON.stringify、それに渡されるオブジェクトの toJSON メソッドを呼び出します)。元の Excel.NumberFormatInfo オブジェクトは API オブジェクトですが、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( Excel.Interfaces.NumberFormatInfoData として型指定) を返します。

プロパティの詳細

context

オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。

context: RequestContext;

プロパティ値

numberDecimalSeparator

数値の小数点として使用される文字列を取得します。 これは、現在のシステム設定に基づいています。

readonly numberDecimalSeparator: string;

プロパティ値

string

注釈

[ API セット: ExcelApi 1.11 ]

// 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

注釈

[ API セット: ExcelApi 1.11 ]

// 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;

パラメーター

options
Excel.Interfaces.NumberFormatInfoLoadOptions

読み込むオブジェクトのプロパティのオプションを提供します。

戻り値

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 オブジェクトがJSON.stringify()に渡されたときにより便利な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (JSON.stringify、それに渡されるオブジェクトの toJSON メソッドを呼び出します)。元の Excel.NumberFormatInfo オブジェクトは API オブジェクトですが、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( Excel.Interfaces.NumberFormatInfoData として型指定) を返します。

toJSON(): Excel.Interfaces.NumberFormatInfoData;

戻り値