[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(Showing Draft Content)

FunctionValueType

Enum Class FunctionValueType

java.lang.Object
java.lang.Enum<FunctionValueType>
com.grapecity.documents.excel.FunctionValueType
All Implemented Interfaces:
Serializable, Comparable<FunctionValueType>, Constable

public enum FunctionValueType extends Enum<FunctionValueType>
指定自定义函数参数或结果的值类型。

将此枚举与 Parameter 和 CustomFunction 一起使用,可以声明自定义函数接受或返回的值种类,例如数字、文本、逻辑值、标量变体或对象。


 class DelayFunction extends AsyncCustomFunction {
     DelayFunction() {
         super("DELAY_SAMPLE", FunctionValueType.Number,
             new Parameter[] { new Parameter(FunctionValueType.Number) });
     }
 
     public CompletableFuture<Object> evaluateAsync(Object[] arguments, ICalcContext context) {
         return CompletableFuture.completedFuture(arguments[0]);
     }
 }
 
 AsyncCustomFunction function = new DelayFunction();
 Workbook.AddCustomFunction(function, true);
 worksheet.getRange("A1").setFormula2("=DELAY_SAMPLE(10)");
 workbook.calculate();
 workbook.waitForCalculationToFinish();
 Object delayedValue = worksheet.getRange("A1").getValue();
 
  • Enum Constant Details

    • Number

      public static final FunctionValueType Number
      Specifies that the parameter value is a number.
    • Text

      public static final FunctionValueType Text
      Specifies that the parameter value is text.
    • Boolean

      public static final FunctionValueType Boolean
      Specifies that the parameter value is a boolean.
    • Variant

      public static final FunctionValueType Variant
      Specifies that the parameter value is a scalar, such as a number, text, boolean, CalcError, or null.
    • Object

      public static final FunctionValueType Object
      指定参数值为对象值,包括标量、Array 或 CalcReference。

      如果参数为 retval 或 acceptCustomObjects,该值也可以是自定义对象。

  • Method Details

    • values

      public static FunctionValueType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static FunctionValueType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getValue

      public int getValue()
      Gets the numeric value of this enum member.
      Returns:
      The zero-based numeric value of this enum member.
    • forValue

      public static FunctionValueType forValue(int value)
      Gets the enum member that corresponds to the specified numeric value.
      Parameters:
      value - The zero-based numeric value.
      Returns:
      The corresponding enum member.