Example usage for org.apache.poi.hssf.usermodel HSSFDataValidation getRegions

List of usage examples for org.apache.poi.hssf.usermodel HSSFDataValidation getRegions

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFDataValidation getRegions.

Prototype

public CellRangeAddressList getRegions() 

Source Link

Usage

From source file:uk.ac.manchester.cs.owl.semspreadsheets.model.hssf.impl.SheetHSSFImpl.java

License:BSD License

public Collection<Validation> getValidations() {
    List<Validation> validationList = new ArrayList<Validation>();
    for (HSSFDataValidation validation : getValidationData()) {
        for (CellRangeAddress address : validation.getRegions().getCellRangeAddresses()) {
            validationList.add(/*from ww w  .  ja  v a  2 s.  c om*/
                    new ValidationImpl(validation.getConstraint().getFormula1(), this, address.getFirstColumn(),
                            address.getLastColumn(), address.getFirstRow(), address.getLastRow()));
        }

    }
    return validationList;
}

From source file:uk.ac.manchester.cs.owl.semspreadsheets.model.hssf.impl.SheetHSSFImplTest.java

License:BSD License

@Test
public void testGetValidationData() throws Exception {
    SheetHSSFImpl sheet = (SheetHSSFImpl) getTestSheet();
    List<HSSFDataValidation> validationData = sheet.getValidationData();
    assertEquals(1, validationData.size());
    HSSFDataValidation val = validationData.get(0);
    CellRangeAddress[] cellRangeAddresses = val.getRegions().getCellRangeAddresses();
    assertEquals(1, cellRangeAddresses.length);
    CellRangeAddress rangeAddresses = cellRangeAddresses[0];
    assertEquals(4, rangeAddresses.getFirstColumn());
    assertEquals(4, rangeAddresses.getLastColumn());
    assertEquals(11, rangeAddresses.getFirstRow());
    assertEquals(11, rangeAddresses.getLastRow());
}