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

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

Introduction

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

Prototype

String getNameName();

Source Link

Document

Gets the name of the named range

Usage

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;
}

From source file:uk.co.spudsoft.birt.emitters.excel.tests.HyperlinksTest.java

License:Open Source License

private void validateNamedRange(Workbook workbook, int index, String name, int sheetIndex, int row1, int col1,
        int row2, int col2) {

    Name namedRange = workbook.getNameAt(index);
    assertEquals(name, namedRange.getNameName());
    assertEquals(sheetIndex, namedRange.getSheetIndex());

    AreaReference ref = new AreaReference(namedRange.getRefersToFormula());

    if ((row1 == row2) && (col1 == col2)) {
        assertTrue(ref.isSingleCell());/*from   ww w .j  a va  2  s . c o  m*/
        assertEquals(row1, ref.getFirstCell().getRow());
        assertEquals(col1, ref.getFirstCell().getCol());
    } else {
        assertTrue(AreaReference.isContiguous(namedRange.getRefersToFormula()));
        assertEquals(row1, Math.min(ref.getFirstCell().getRow(), ref.getLastCell().getRow()));
        assertEquals(col1, Math.min(ref.getFirstCell().getCol(), ref.getLastCell().getCol()));
        assertEquals(row2, Math.max(ref.getFirstCell().getRow(), ref.getLastCell().getRow()));
        assertEquals(col2, Math.max(ref.getFirstCell().getCol(), ref.getLastCell().getCol()));
    }
}