ExcelScript.DataValidationType enum

表示数据验证类型枚举。

注解

示例

/**
 * This sample reads and logs the data validation type of the currently selected range.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the currently selected range.
  let range = workbook.getSelectedRange();

  // Get the type (`DataValidationType`) of data validation applied to the range.
  let validationType = range.getDataValidation().getType();

  /*
   * Log the data validation type.
   * If the range has a single value, it logs that type.
   * If the range doesn't have data validation applied, it logs "None".
   * If the range has multiple different types of data validation, it logs "Inconsistent" or "MixedCriteria".
   */
  console.log(validationType.toString());
}

字段

custom

自定义数据验证类型。

date

日期数据验证类型。

decimal

十进制数据验证类型。

inconsistent

不一致意味着区域的数据验证不一致,指示不同单元格上存在不同的规则。

list

列表数据验证类型。

mixedCriteria

混合条件意味着区域在某些单元格(但不是所有单元格)上存在数据验证。

none

“无”表示允许任何值,指示区域中没有数据验证。

textLength

文本长度数据验证类型。

time

时间数据验证类型。

wholeNumber

整数数据验证类型。