use of org.apache.poi.ss.formula.functions.FreeRefFunction in project poi by apache.
the class ExcelAntWorkbookUtil method getFunctions.
/**
* returns a UDFFinder that contains all of the functions added.
*
* @return
*/
protected UDFFinder getFunctions() {
String[] names = new String[xlsMacroList.size()];
FreeRefFunction[] functions = new FreeRefFunction[xlsMacroList.size()];
int x = 0;
for (Map.Entry<String, FreeRefFunction> entry : xlsMacroList.entrySet()) {
names[x] = entry.getKey();
functions[x] = entry.getValue();
}
UDFFinder udff1 = new DefaultUDFFinder(names, functions);
UDFFinder udff = new AggregatingUDFFinder(udff1);
return udff;
}
use of org.apache.poi.ss.formula.functions.FreeRefFunction in project poi by apache.
the class BaseXSSFEvaluationWorkbook method getNameXPtg.
/**
* Return an external name (named range, function, user-defined function) Pxg
*/
@Override
public NameXPxg getNameXPtg(String name, SheetIdentifier sheet) {
// First, try to find it as a User Defined Function
IndexedUDFFinder udfFinder = (IndexedUDFFinder) getUDFFinder();
FreeRefFunction func = udfFinder.findFunction(name);
if (func != null) {
return new NameXPxg(null, name);
}
// Otherwise, try it as a named range
if (sheet == null) {
if (!_uBook.getNames(name).isEmpty()) {
return new NameXPxg(null, name);
}
return null;
}
if (sheet._sheetIdentifier == null) {
// Workbook + Named Range only
int bookIndex = resolveBookIndex(sheet._bookName);
return new NameXPxg(bookIndex, null, name);
}
// Use the sheetname and process
String sheetName = sheet._sheetIdentifier.getName();
if (sheet._bookName != null) {
int bookIndex = resolveBookIndex(sheet._bookName);
return new NameXPxg(bookIndex, sheetName, name);
} else {
return new NameXPxg(sheetName, name);
}
}
use of org.apache.poi.ss.formula.functions.FreeRefFunction in project poi by apache.
the class BaseTestUDFFinder method confirmFindFunction.
protected void confirmFindFunction(String name) {
FreeRefFunction func = _instance.findFunction(name);
assertNotNull(func);
}
Aggregations