Example usage for org.apache.poi.ss.util AreaReference isSingleCell

List of usage examples for org.apache.poi.ss.util AreaReference isSingleCell

Introduction

In this page you can find the example usage for org.apache.poi.ss.util AreaReference isSingleCell.

Prototype

public boolean isSingleCell() 

Source Link

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());
        assertEquals(row1, ref.getFirstCell().getRow());
        assertEquals(col1, ref.getFirstCell().getCol());
    } else {//from w w w.  java2  s.co  m
        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()));
    }
}