Interface TypedUserFunction

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface TypedUserFunction
A typed user-defined formula function. Register with Workbook.registerTypedFunction(name, fn); the engine calls it when a formula uses that name.

Argument shapes. Each argument arrives as the CellValue the engine evaluated for it:

  • a number, text, boolean, error, or blank operand arrives as CellValue.Number, CellValue.Text, CellValue.Bool, CellValue.Error, or CellValue.Blank respectively — including a single-cell reference, which arrives as that cell's scalar value;
  • a range (area) argument such as A1:B2 arrives as CellValue.Array: the engine evaluates an area reference to a row-major two-dimensional array of its cell values, and that shape is mirrored across the bridge as a rectangular CellValue[][] (rows of columns). Constant array literals like {1,2;3,4} arrive the same way.

Return. Return any scalar CellValue — number, text, boolean, error (an error return becomes the formula's error value, e.g. CellValue.error(7) yields #N/A), or blank. Returning a CellValue.Array produces an array result, which the engine treats like any other array-valued function result. Returning null is a contract violation and surfaces as #VALUE!.

A UDF must not call back into the same workbook while it runs (the engine holds the workbook during evaluation). A UDF that throws is not swallowed — the native bridge maps the pending JVM exception to a #VALUE! error value.

  • Method Summary

    Modifier and Type
    Method
    Description
    apply(CellValue[] args)