true
if this is an external function
*/
public boolean isExternalFunction() {
return field_2_fnc_index == FUNCTION_INDEX_EXTERNAL;
}
public String toFormulaString(HSSFWorkbook book) {
return getName();
}
public String toFormulaString(String[] operands) {
StringBuffer buf = new StringBuffer();
if(isExternalFunction()) {
buf.append(operands[0]); // first operand is actually the function name
appendArgs(buf, 1, operands);
} else {
buf.append(getName());
appendArgs(buf, 0, operands);
}
return buf.toString();
}
private static void appendArgs(StringBuffer buf, int firstArgIx, String[] operands) {
buf.append('(');
for (int i=firstArgIx;i
* The name matching is case insensitive.
* @return true
if the name specifies a standard worksheet function,
* false
if the name should be assumed to be an external function.
*/
public static final boolean isInternalFunctionName(String name) {
short ix = FunctionMetadataRegistry.lookupIndexByName(name.toUpperCase());
return ix >= 0;
}
protected String lookupName(short index) {
if(index == FunctionMetadataRegistry.FUNCTION_INDEX_EXTERNAL) {
return "#external#";
}
FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByIndex(index);
if(fm == null) {
throw new RuntimeException("bad function index (" + index + ")");
}
return fm.getName();
}
/**
* Resolves internal function names into function indexes.
*
* The name matching is case insensitive. * @return the standard worksheet function index if found, otherwise FUNCTION_INDEX_EXTERNAL */ protected static short lookupIndex(String name) { short ix = FunctionMetadataRegistry.lookupIndexByName(name.toUpperCase()); if (ix < 0) { return FUNCTION_INDEX_EXTERNAL; } return ix; } public byte getDefaultOperandClass() { return returnClass; } public byte getParameterClass(int index) { if (index >= paramClass.length) { // For var-arg (and other?) functions, the metadata does not list all the parameter // operand classes. In these cases, all extra parameters are assumed to have the // same operand class as the last one specified. return paramClass[paramClass.length - 1]; } return paramClass[index]; } }