Excel.NumberFormatInfo class

文化的に適切な表示形式を定義します。 これは、現在のシステム カルチャの設定に基づいています。

Extends

プロパティ

context

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

currencySymbol

通貨値の通貨記号を取得します。 これは、現在のシステム設定に基づいています。

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;

プロパティ値

currencySymbol

通貨値の通貨記号を取得します。 これは、現在のシステム設定に基づいています。

readonly currencySymbol: string;

プロパティ値

string

注釈

API セット: ExcelApi 1.17

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;

返品