Annotation Interface ExcelFunction


@Target(METHOD) @Retention(RUNTIME) public @interface ExcelFunction

ExcelFunction annotation for methods that should be exposed as Excel worksheet functions.

ExcelArguments and ExcelArgument can also be used to provide argument documentation.

Static and non-static methods can be used. For non-static methods, the class must have a public constructor taking either no parameters or a single ExcelAddIn parameter.

Example:


 public class WorksheetFunctions {
     @ExcelFunction(
            value = "jinx.multiplyAndAdd",
           description = "Simple function that returns (x * y) + z"
     )
     @ExcelArguments({
          @ExcelArgument("x"),
          @ExcelArgument("y"),
          @ExcelArgument("z")
     })
     public static double multiplyAndAdd(int x, double y, double z) {
          return (x * y) + z;
     }
 }
 
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Not currently used.
    boolean
    For functions returning arrays, if autoResize is true the formula will automatically be resized to match the dimensions of the returned array.
    Category the function will appear under in the Excel function wizard.
    Description shown in the Excel function wizard.
    boolean
    Disable calling the method when being called from the Excel Function Wizard.
    Not currently used.
    boolean
    Hidden functions do not appear in the Excel function wizard or show up when using in-sheet IntelliSense.
    boolean
    Register the function as a macro sheet equivalent function.
    boolean
    Thread safe functions may be run by Excel in threads other than the main thread when it determines there may be a performance benefit to doing so, depending on the number of calculation threads available.
    boolean
    Volatile functions are calculated when Excel recalculates regardless of whether any inputs have changed or not.
    boolean
    If true then the calling cell will be marked as dirty when the workbook is opened.
    boolean
    If the result of the function is an array, transpose the array before returning to Excel.
    Name of the function as it will appear in Excel.
  • Element Details

    • value

      String value
      Name of the function as it will appear in Excel.
      Default:
      ""
    • description

      String description
      Description shown in the Excel function wizard.
      Default:
      ""
    • category

      String category
      Category the function will appear under in the Excel function wizard.
      Default:
      "Jinx"
    • helpTopic

      String helpTopic
      Not currently used.
      Default:
      ""
    • isVolatile

      boolean isVolatile
      Volatile functions are calculated when Excel recalculates regardless of whether any inputs have changed or not.
      Default:
      false
    • isMacroType

      boolean isMacroType
      Register the function as a macro sheet equivalent function.
      Default:
      false
    • isThreadSafe

      boolean isThreadSafe
      Thread safe functions may be run by Excel in threads other than the main thread when it determines there may be a performance benefit to doing so, depending on the number of calculation threads available.
      Default:
      false
    • isHidden

      boolean isHidden
      Hidden functions do not appear in the Excel function wizard or show up when using in-sheet IntelliSense.
      Default:
      false
    • allowAbort

      boolean allowAbort
      Not currently used.
      Default:
      false
    • autoResize

      boolean autoResize

      For functions returning arrays, if autoResize is true the formula will automatically be resized to match the dimensions of the returned array.

      Note:RTD functions will not be automatically resized. If you require an auto-resizing RTD function, have your RTD function return an Object and use a second non-RTD function to expand the result.

      Default:
      false
    • disableInFunctionWizard

      boolean disableInFunctionWizard
      Disable calling the method when being called from the Excel Function Wizard. This is useful for slow calculations where calling the method from the function wizard causes Excel to respond very slowly.
      Default:
      false
    • transpose

      boolean transpose
      If the result of the function is an array, transpose the array before returning to Excel. This can be used for returning a 1d array as a row instead of a column, for example.
      Default:
      false
    • recalculateOnOpen

      boolean recalculateOnOpen

      If true then the calling cell will be marked as dirty when the workbook is opened. The next time Excel recalculates then the cell will be recalculated, which will be immediately on opening if automatic calculations are enabled.

      This can be useful for functions returning cached objects to ensure that the object is created each time the workbook is opened.

      Default:
      false