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

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

Introduction

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

Prototype

public int getSheetIndex();

Source Link

Document

Returns the sheet index this name applies to.

Usage

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   w w w . j  a v a  2  s  . co 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()));
    }
}