Search in sources :

Example 1 with HSSFDataValidation

use of org.apache.poi.hssf.usermodel.HSSFDataValidation in project poi by apache.

the class TestPLVRecord method testPLVRecord.

public void testPLVRecord() throws Exception {
    InputStream is = HSSFTestDataSamples.openSampleFileStream(XLS_FILENAME);
    HSSFWorkbook workbook = new HSSFWorkbook(is);
    CellRangeAddressList cellRange = new CellRangeAddressList(0, 0, 1, 1);
    DataValidationConstraint constraint = DVConstraint.createFormulaListConstraint(DV_DEFINITION);
    HSSFDataValidation dataValidation = new HSSFDataValidation(cellRange, constraint);
    // This used to throw an error before
    try {
        workbook.getSheet(SHEET_NAME).addValidationData(dataValidation);
    } catch (IllegalStateException ex) {
        throw new AssertionFailedError("Identified bug 53972, PLV record breaks addDataValidation()");
    }
}
Also used : HSSFDataValidation(org.apache.poi.hssf.usermodel.HSSFDataValidation) InputStream(java.io.InputStream) DataValidationConstraint(org.apache.poi.ss.usermodel.DataValidationConstraint) CellRangeAddressList(org.apache.poi.ss.util.CellRangeAddressList) AssertionFailedError(junit.framework.AssertionFailedError) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook)

Aggregations

InputStream (java.io.InputStream)1 AssertionFailedError (junit.framework.AssertionFailedError)1 HSSFDataValidation (org.apache.poi.hssf.usermodel.HSSFDataValidation)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1 DataValidationConstraint (org.apache.poi.ss.usermodel.DataValidationConstraint)1 CellRangeAddressList (org.apache.poi.ss.util.CellRangeAddressList)1