ajCallFunction function
Description
The ajCallFunction function executes a native Java class method at runtime.
Please take note that the AlchemyJ Studio in Microsoft Excel is not able to trigger and run the Java class method after pressing Run Function Point. However, you can create a macro that simulates the corresponding return result of the Java method in VBA.
Syntax
ajCallFunction(class_name, is_instance, constructor_parameter, method_name, method_parameter, [run_condition], [run_by_function_point_only])
Argument Name | Description |
---|---|
class_name (required) | Specify the Java class name, e.g. com.axisoft.alchemyj.test.ajCallFunctionExample. If using the simulation program generated by Microsoft Excel macro, specify the module name of Microsoft Excel macro. |
is_instance (required) | If it equals FALSE, during compilation, AlchemyJ will execute the call as a static method. If it equals TRUE, during compilation, AlchemyJ will execute the call as an instance method. If you do not specify anything, the default value will always be FALSE. |
constructor_parameter (required) | Specify the parameters to be keyed into the method constructor in the format below. The following data types are supported: String, java.lang.string, Boolean, boolean, int, Integer, Double, double, Long, long, Float, float, date and java.util.date. <field_name>-##-<value>-##-<data_type>-||- <field_name>-##-<value>-##-<data_type>-||-... Where, -||- denotes AlchemyJ parameter separator. -##- denotes AlchemyJ parameter type separator. For example, ID-##-number-||-Name-##-string Please take note that both separator symbols can be configured in %%AppConfig Worksheet. |
method_name (required) | Specify the method name in the class to be called. Please take note that it is also the function name in the Microsoft Excel macro. |
method_parameter (required) | Specify the parameters to be keyed into the method in the format below. The following data types are supported: String - java.lang.string Boolean - boolean Integer - int Double - double Long - long Float - float date - java.util.date <field_name>-##-<value>-##-<data_type>-||- <field_name>-##-<value>-##-<data_type>-||-... Where, -||- denotes AlchemyJ parameter separator. -##- denotes AlchemyJ parameter type separator. For example, ID-##-number-||-Name-##-string Please take note that both separator symbols can be configured in %%AppConfig Worksheet. |
run_condition (optional) | The function will run when the value is TRUE. Otherwise, it will not run. If you do not specify anything, the default value will always be TRUE. |
run_by_function_point_only (optional) | If it equals FALSE, the function can be executed through ‘Excel Calculation’ (can be either Automatic or Manual, Calculate Now or Calculate Sheet) or Run Function Point. If it equals TRUE, the function can be executed with Run Function Point (AlchemyJ toolbar \ Run Function Point) only. If you do not specify anything, the default value will always be TRUE. |
The function will return:
1) Content type: The result of the Java or Excel macro function
2) Method: Within a cell
Example using Excel macro simulation program
As you can see from the above example, ajCallFunction is successful and the result of the macro is returned. Otherwise, it will return #VALUE!.
Please take note that AlchemyJ will not compile the macro into JAR/WAR when building the project. This function in Microsoft Excel acts as a simulator that calls the other Java class at runtime.