Example usage for org.apache.poi.ss.usermodel Name isFunctionName

List of usage examples for org.apache.poi.ss.usermodel Name isFunctionName

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Name isFunctionName.

Prototype

boolean isFunctionName();

Source Link

Document

Checks if this name is a function name

Usage

From source file:com.dataart.spreadsheetanalytics.engine.PoiWorkbookConverters.java

License:Apache License

private Map<Integer, PoiProxyName> makeNames(Workbook wb, EvaluationWorkbook ewb) {
    Map<Integer, PoiProxyName> names = new HashMap<>();

    for (int nIdx = 0; nIdx < wb.getNumberOfNames(); nIdx++) {
        Name wbName = wb.getNameAt(nIdx);

        Ptg[] ptgs;//from ww w  . j a  va  2  s.  c o m
        String refersToFormula;
        if (!wbName.isFunctionName() && wbName.getRefersToFormula() != null) { //NOPMD
            refersToFormula = wbName.getRefersToFormula();
            ptgs = FormulaParser.parse(refersToFormula, (FormulaParsingWorkbook) ewb, FormulaType.NAMEDRANGE,
                    0 /*TODO: sheet index*/);
        } else {
            ptgs = null;
            refersToFormula = null;
        }

        names.put(nIdx, new PoiProxyName(wbName.getNameName(), wbName.isFunctionName(), refersToFormula != null,
                ptgs, wbName.isFunctionName(), nIdx));
    }

    return names;
}

From source file:org.formulacompiler.spreadsheet.internal.excel.xls.loader.ExcelXLSLoader.java

License:Open Source License

private void loadNames(Workbook _xlsWorkbook, BaseSpreadsheet _spreadsheet) {
    final int numberOfNames = _xlsWorkbook.getNumberOfNames();
    for (int nameIndex = 0; nameIndex < numberOfNames; nameIndex++) {
        final Name name = _xlsWorkbook.getNameAt(nameIndex);
        if (name.isFunctionName())
            continue;

        final String cellRangeAddress = name.getRefersToFormula();
        final String rangeName = name.getNameName();

        final ExpressionParser parser = new SpreadsheetExpressionParserA1OOXML(cellRangeAddress, _spreadsheet);
        try {// w w  w. j  av  a2 s.  co  m
            final CellRange cellRange = (CellRange) parser.rangeOrCellRefA1();
            _spreadsheet.defineModelRangeName(rangeName, cellRange);
        } catch (ParseException e) {
            // Ignore all non 'named range' names
        }
    }
}

From source file:org.formulacompiler.spreadsheet.internal.excel.xls.loader.ExcelXLSLoader.java

License:Open Source License

private Cell getCellByName(String _name, Workbook _workbook, BaseSpreadsheet _spreadsheet) {
    final Name name = _workbook.getName(_name);
    if (name == null)
        return null;
    if (name.isFunctionName())
        return null;

    final String cellRangeAddress = name.getRefersToFormula();

    final ExpressionParser parser = new SpreadsheetExpressionParserA1OOXML(cellRangeAddress, _spreadsheet);
    try {/*from   w  w w.ja va2  s  . c  om*/
        final CellRange range = (CellRange) parser.rangeOrCellRefA1();
        if (!(range instanceof CellIndex)) {
            return null;
        }
        final CellIndex cellIndex = (CellIndex) range;
        final int sheetIndex = cellIndex.getSheetIndex();
        final int rowIndex = cellIndex.getRowIndex();
        final int columnIndex = cellIndex.getColumnIndex();
        return _workbook.getSheetAt(sheetIndex).getRow(rowIndex).getCell(columnIndex);
    } catch (ParseException e) {
        // Ignore all non 'named range' names
        return null;
    }
}

From source file:org.jreserve.gui.poi.ExcelUtil.java

License:Open Source License

public static boolean isReferenceName(Workbook wb, Name name) {
    return !name.isFunctionName() && !name.isDeleted() && wb.getSheetIndex(name.getNameName()) < 0;
}