ExcelFunction Options

The @ExcelFunction annotation takes a number of optional parameters. These are used to control how the Java method is exposed to Excel.

Option Meaning Default
value The function name as it appears in Excel The method name
description Function description shown in the Excel function wizard none
category The category the function will appear under in Excel’s function list Jinx
isVolatile Volatile functions are called every time a worksheet is calculated, even if nothing has changed false
isMacroType “Macro type equivalent” functions are less restricted in terms of what Excel API functions they can call false
isThreadSafe Excel may call thread safe functions in threads other than the main thread to improve performance false
isHidden Don’t show the function in the Excel function wizard or in-sheet IntelliSense false
autoResize For array functions, automatically resize the range of the formuala to fit the size of the returned array false
disableInFunctionWizard Disable the method when being called from the Excel function wizard. false
recalculateOnOpen Recalculate any cells using this function when opening a workbook 1. false

It can be useful to use different names and categories for functions to distinguish between your functions and those of other add-ins or Excel’s own functions. For example, the following function has a different name from the method it wraps, and is marked as being thread-safe:

import com.exceljava.jinx.ExcelFunction;

class MyFunction {
    @ExcelFunction(
        value = "HardSums.DoSomething",
        description = "Helpful text for someone who wants to use this",
        category = "Hard Sums",
        isThreadSafe = true
    )
    public static double doSomething(double x, double y) {
        double z = HardSums.someComplexAlgorithm(x, y);
        return z;
    }
}

This method would be called in Excel as =HardSums.DoSomething(x, y).

  1. Recalculating on open is only available in Jinx 2.2 and later versions. The function must be calculated at least once before saving.