ExcelScript.NumberFormatCategory enum

表示数字格式的类别。

注解

示例

/**
 * 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");
    }
  }); 
}

字段

accounting

会计格式将列中的货币符号和小数点对齐。

currency

货币格式用于常规货币值。 使用会计格式对齐列中的小数点。

custom

不属于任何类别的自定义格式。

date

日期格式将日期和时间序列号显示为日期值。 以星号 (*开头的日期格式) 响应为操作系统指定的区域日期和时间设置中的更改。 没有星号的格式不受操作系统设置的影响。

fraction

分数格式将单元格值显示为整数,余数舍入为最接近的分数值。

general

常规格式单元格没有特定的数字格式。

number

数字用于数字的常规显示。 货币和会计为货币值提供专用格式设置。

percentage

百分比格式将单元格值乘以 100,并使用百分比符号显示结果。

scientific

科学格式将单元格值显示为介于 1 和 10 之间的数字乘以 10 的幂。

special

特殊格式可用于跟踪列表和数据库值。

text

即使单元格中有数字,文本格式单元格也会被视为文本。 单元格的显示方式与输入的完全一致。

time

时间格式将日期和时间序列号显示为日期值。 以星号 (*开头的时间格式) 响应为操作系统指定的区域日期和时间设置中的更改。 没有星号的格式不受操作系统设置的影响。