CustomFunctions.ErrorCode enum

自定义函数的错误代码。 错误代码将显示在调用函数的单元格中。

除了这些错误代码外,还显示自定义错误消息。 自定义消息显示在错误指示器菜单中,可以通过将鼠标悬停在每个单元格上的错误标志上并显示错误来访问该菜单。

注解

示例

/**
 * Returns the #NUM! error as part of a 2-dimensional array.
 * @customfunction
 * @param {number} first First parameter.
 * @param {number} second Second parameter.
 * @param {number} third Third parameter.
 * @returns {number[][]} Three results, as a 2-dimensional array.
 */
function returnInvalidNumberError(first, second, third) {
  // Use the `CustomFunctions.Error` object to retrieve an invalid number error.
  const error = new CustomFunctions.Error(
    CustomFunctions.ErrorCode.invalidNumber, // Corresponds to the #NUM! error in the Excel UI.
  );

  // Enter logic that processes the first, second, and third input parameters.
  // Imagine that the second calculation results in an invalid number error.
  const firstResult = first;
  const secondResult = error;
  const thirdResult = third;

  // Return the results of the first and third parameter calculations
  // and a #NUM! error in place of the second result.
  return [[firstResult], [secondResult], [thirdResult]];
  };

字段

divisionByZero = "#DIV/0!"

此错误代码指示使用的函数除以零个单元格或空单元格。 无法使用自定义错误消息。

invalidName = "#NAME?"

此错误代码指示函数名称中存在拼写错误。 请注意,支持将此错误代码作为自定义函数输入错误,但不支持作为自定义函数输出错误。 无法使用自定义错误消息。

invalidNumber = "#NUM!"

此错误代码指示函数中的数字存在问题。 无法使用自定义错误消息。

invalidReference = "#REF!"

此错误代码指示函数引用无效的单元格。 请注意,支持将此错误代码作为自定义函数输入错误,但不支持作为自定义函数输出错误。 无法使用自定义错误消息。

invalidValue = "#VALUE!"

此错误代码指示函数中的值属于错误的数据类型。 如果需要,除了错误代码之外,还可以使用自定义错误消息。

notAvailable = "#N/A"

此错误代码指示函数或服务不可用。 如果需要,除了错误代码之外,还可以使用自定义错误消息。

nullReference = "#NULL!"

此错误代码指示 函数中的范围不相交。 无法使用自定义错误消息。