Excel.FormattedNumberCellValue interface

書式指定文字列を含む数値を含むセルの値を表します。 数値書式指定文字列は、Excel のガイドラインに準拠している必要があります。 詳細については、「 数値形式をカスタマイズするためのガイドラインを確認する」を参照してください。 このシナリオでは、書式はセルではなく値に適用されるため、値は計算全体でその書式文字列を保持します。

注釈

[ API セット: ExcelApi 1.16 ]

プロパティ

basicType

この値を持つセルの によって Range.valueTypes 返される値を表します。

basicValue

この値を持つセルの によって Range.values 返される値を表します。

numberFormat

この値を表示するために使用される数値書式指定文字列を返します。 プロパティを valuesAsJson 介してアクセスすると、この数値書式指定文字列は en-US ロケールになります。 プロパティを valuesAsJsonLocal 介してアクセスすると、この数値形式はユーザーの表示ロケールになります。 数値書式指定文字列は、Excel のガイドラインに準拠している必要があります。 詳細については、「 数値形式をカスタマイズするためのガイドラインを確認する」を参照してください。

type

このセル値の型を表します。

プロパティの詳細

basicType

この値を持つセルの によって Range.valueTypes 返される値を表します。

basicType?: RangeValueType.double | "Double";

プロパティ値

double | "Double"

注釈

[ API セット: ExcelApi 1.16 ]

basicValue

この値を持つセルの によって Range.values 返される値を表します。

basicValue: number;

プロパティ値

number

注釈

[ API セット: ExcelApi 1.16 ]

numberFormat

この値を表示するために使用される数値書式指定文字列を返します。 プロパティを valuesAsJson 介してアクセスすると、この数値書式指定文字列は en-US ロケールになります。 プロパティを valuesAsJsonLocal 介してアクセスすると、この数値形式はユーザーの表示ロケールになります。 数値書式指定文字列は、Excel のガイドラインに準拠している必要があります。 詳細については、「 数値形式をカスタマイズするためのガイドラインを確認する」を参照してください。

numberFormat: string;

プロパティ値

string

注釈

[ API セット: ExcelApi 1.16 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml

// This function creates a formatted number data type,
// and sets the format of this data type as a currency.
await Excel.run(async (context) => {
  // Get the Sample worksheet and a range on that sheet.
  const sheet = context.workbook.worksheets.getItemOrNullObject("Sample");
  const currencyRange = sheet.getRange("A2");

  // Write a number formatted as currency to cell A2.
  currencyRange.valuesAsJson = [
    [
      {
        type: Excel.CellValueType.formattedNumber,
        basicValue: 12.34,
        numberFormat: "$* #,##0.00"
      }
    ]
  ];

  await context.sync();
});

type

このセル値の型を表します。

type: CellValueType.formattedNumber | "FormattedNumber";

プロパティ値

formattedNumber | "FormattedNumber"

注釈

[ API セット: ExcelApi 1.16 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml

// This function creates a formatted number data type,
// and sets the format of this data type as a date.
await Excel.run(async (context) => {
  // Get the Sample worksheet and a range on that sheet.
  const sheet = context.workbook.worksheets.getItemOrNullObject("Sample");
  const dateRange = sheet.getRange("A1");

  // Write a number formatted as a date to cell A1.
  dateRange.valuesAsJson = [
    [
      {
        type: Excel.CellValueType.formattedNumber,
        basicValue: 32889.0,
        numberFormat: "m/d/yyyy"
      }
    ]
  ];
  await context.sync();
});