Search in sources :

Example 1 with IndexedUDFFinder

use of org.apache.poi.ss.formula.udf.IndexedUDFFinder in project poi by apache.

the class BaseXSSFEvaluationWorkbook method resolveNameXText.

@Override
public String resolveNameXText(NameXPtg n) {
    int idx = n.getNameIndex();
    String name = null;
    // First, try to find it as a User Defined Function
    IndexedUDFFinder udfFinder = (IndexedUDFFinder) getUDFFinder();
    name = udfFinder.getFunctionName(idx);
    if (name != null)
        return name;
    // Otherwise, try it as a named range
    XSSFName xname = _uBook.getNameAt(idx);
    if (xname != null) {
        name = xname.getNameName();
    }
    return name;
}
Also used : IndexedUDFFinder(org.apache.poi.ss.formula.udf.IndexedUDFFinder)

Example 2 with IndexedUDFFinder

use of org.apache.poi.ss.formula.udf.IndexedUDFFinder 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);
    }
}
Also used : NameXPxg(org.apache.poi.ss.formula.ptg.NameXPxg) IndexedUDFFinder(org.apache.poi.ss.formula.udf.IndexedUDFFinder) FreeRefFunction(org.apache.poi.ss.formula.functions.FreeRefFunction)

Aggregations

IndexedUDFFinder (org.apache.poi.ss.formula.udf.IndexedUDFFinder)2 FreeRefFunction (org.apache.poi.ss.formula.functions.FreeRefFunction)1 NameXPxg (org.apache.poi.ss.formula.ptg.NameXPxg)1