Annotation 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 ElementsModifier and TypeOptional ElementDescriptionbooleanNot currently used.booleanFor 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.booleanDisable calling the method when being called from the Excel Function Wizard.Not currently used.booleanHidden functions do not appear in the Excel function wizard or show up when using in-sheet IntelliSense.booleanRegister the function as a macro sheet equivalent function.booleanThread 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.booleanVolatile functions are calculated when Excel recalculates regardless of whether any inputs have changed or not.booleanIf true then the calling cell will be marked as dirty when the workbook is opened.booleanIf 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 valueName of the function as it will appear in Excel.- Default:
""
-
description
String descriptionDescription shown in the Excel function wizard.- Default:
""
-
category
String categoryCategory the function will appear under in the Excel function wizard.- Default:
"Jinx"
-
helpTopic
String helpTopicNot currently used.- Default:
""
-
isVolatile
boolean isVolatileVolatile functions are calculated when Excel recalculates regardless of whether any inputs have changed or not.- Default:
false
-
isMacroType
boolean isMacroTypeRegister the function as a macro sheet equivalent function.- Default:
false
-
isThreadSafe
boolean isThreadSafeThread 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 isHiddenHidden functions do not appear in the Excel function wizard or show up when using in-sheet IntelliSense.- Default:
false
-
allowAbort
boolean allowAbortNot currently used.- Default:
false
-
autoResize
boolean autoResizeFor 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 disableInFunctionWizardDisable 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 transposeIf 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 recalculateOnOpenIf 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
-