ExcelScript.NumberFormatCategory enum

Represents a category of number formats.

Remarks

Examples

/**
 * This script finds cells in a table column that are not formatted as currency
 * and sets the fill color to red.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the "Cost" column from the "Expenses" table.
  const table = workbook.getTable("Expenses");
  const costColumn = table.getColumnByName("Cost");
  const costColumnRange = costColumn.getRangeBetweenHeaderAndTotal();

  // Get the number format categories for the column's range.
  const numberFormatCategories = costColumnRange.getNumberFormatCategories();

  // If any cell in the column doesn't have a currency format, make the cell red.
  numberFormatCategories.forEach((category, index) =>{
    if (category[0] != ExcelScript.NumberFormatCategory.currency) {
      costColumnRange.getCell(index, 0).getFormat().getFill().setColor("red");
    }
  }); 
}

Fields

accounting

Accounting formats line up the currency symbols and decimal points in a column.

currency

Currency formats are used for general monetary values. Use Accounting formats to align decimal points in a column.

custom

A custom format that is not a part of any category.

date

Date formats display date and time serial numbers as date values. Date formats that begin with an asterisk (*) respond to changes in regional date and time settings that are specified for the operating system. Formats without an asterisk are not affected by operating system settings.

fraction

Fraction formats display the cell value as a whole number with the remainder rounded to the nearest fraction value.

general

General format cells have no specific number format.

number

Number is used for general display of numbers. Currency and Accounting offer specialized formatting for monetary value.

percentage

Percentage formats multiply the cell value by 100 and displays the result with a percent symbol.

scientific

Scientific formats display the cell value as a number between 1 and 10 multiplied by a power of 10.

special

Special formats are useful for tracking list and database values.

text

Text format cells are treated as text even when a number is in the cell. The cell is displayed exactly as entered.

time

Time formats display date and time serial numbers as date values. Time formats that begin with an asterisk (*) respond to changes in regional date and time settings that are specified for the operating system. Formats without an asterisk are not affected by operating system settings.