Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.DataValidationConstraint$ValidationType


            int lastRow, int lastCol) {
        assert sheet != null;
        assert list != null;
        DataValidationHelper helper = sheet.getDataValidationHelper();
        CellRangeAddressList addressList = new CellRangeAddressList(firstRow, lastRow, firstCol, lastCol);
        DataValidationConstraint constraint = helper.createExplicitListConstraint(list);
        DataValidation validation = helper.createValidation(constraint, addressList);
        validation.setEmptyCellAllowed(true);
        sheet.addValidationData(validation);
    }
View Full Code Here


        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("Sheet1");
        sheet.protectSheet("secret");

        DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
        DataValidationConstraint dvc = dataValidationHelper.createIntegerConstraint(DataValidationConstraint.OperatorType.BETWEEN, "10", "100");
        CellRangeAddressList numericCellAddressList = new CellRangeAddressList(0, 0, 1, 1);
        DataValidation dv = dataValidationHelper.createValidation(dvc,numericCellAddressList);
        try {
            sheet.addValidationData(dv);
        } catch (IllegalStateException e) {
View Full Code Here

        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("Sheet1");
        sheet.protectSheet("secret");

        DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
        DataValidationConstraint dvc = dataValidationHelper.createIntegerConstraint(DataValidationConstraint.OperatorType.BETWEEN, "10", "100");
        CellRangeAddressList numericCellAddressList = new CellRangeAddressList(0, 0, 1, 1);
        DataValidation dv = dataValidationHelper.createValidation(dvc,numericCellAddressList);
        try {
            sheet.addValidationData(dv);
        } catch (IllegalStateException e) {
View Full Code Here

    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);
View Full Code Here

        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("Sheet1");
        sheet.protectSheet("secret");

        DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
        DataValidationConstraint dvc = dataValidationHelper.createIntegerConstraint(DataValidationConstraint.OperatorType.BETWEEN, "10", "100");
        CellRangeAddressList numericCellAddressList = new CellRangeAddressList(0, 0, 1, 1);
        DataValidation dv = dataValidationHelper.createValidation(dvc,numericCellAddressList);
        try {
            sheet.addValidationData(dv);
        } catch (IllegalStateException e) {
View Full Code Here

        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("Sheet1");
        sheet.protectSheet("secret");

        DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
        DataValidationConstraint dvc = dataValidationHelper.createIntegerConstraint(DataValidationConstraint.OperatorType.BETWEEN, "10", "100");
        CellRangeAddressList numericCellAddressList = new CellRangeAddressList(0, 0, 1, 1);
        DataValidation dv = dataValidationHelper.createValidation(dvc,numericCellAddressList);
        try {
            sheet.addValidationData(dv);
        } catch (IllegalStateException e) {
View Full Code Here

        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet("Sheet1");
        sheet.protectSheet("secret");

        DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
        DataValidationConstraint dvc = dataValidationHelper.createIntegerConstraint(DataValidationConstraint.OperatorType.BETWEEN, "10", "100");
        CellRangeAddressList numericCellAddressList = new CellRangeAddressList(0, 0, 1, 1);
        DataValidation dv = dataValidationHelper.createValidation(dvc,numericCellAddressList);
        try {
            sheet.addValidationData(dv);
        } catch (IllegalStateException e) {
View Full Code Here

    // and then deleting the row that contains the cell.
    HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("dvEmpty.xls")
    int dvRow = 0;
    Sheet sheet = wb.getSheetAt(0);
    DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
    DataValidationConstraint dc = dataValidationHelper.createIntegerConstraint(OP.EQUAL, "42", null);
    DataValidation dv = dataValidationHelper.createValidation(dc,new CellRangeAddressList(dvRow, dvRow, 0, 0));
   
    dv.setEmptyCellAllowed(false);
    dv.setErrorStyle(ES.STOP);
    dv.setShowPromptBox(true);
View Full Code Here

        HSSFSheet sheet = wb.createSheet();
        List<HSSFDataValidation> list = sheet.getDataValidations();
        assertEquals(0, list.size());

        DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
        DataValidationConstraint constraint = dataValidationHelper.createNumericConstraint(ValidationType.ANY,
                OperatorType.IGNORED, null, null);
        CellRangeAddressList addressList = new CellRangeAddressList(1, 2, 3, 4);
        DataValidation validation = dataValidationHelper.createValidation(constraint, addressList);
        validation.setEmptyCellAllowed(true);
        validation.createErrorBox("error-title", "error-text");
        validation.createPromptBox("prompt-title", "prompt-text");
        sheet.addValidationData(validation);

        list = sheet.getDataValidations(); // <-- works
        assertEquals(1, list.size());

        HSSFDataValidation dv = list.get(0);
        {
            CellRangeAddressList regions = dv.getRegions();
            assertEquals(1, regions.countRanges());

            CellRangeAddress address = regions.getCellRangeAddress(0);
            assertEquals(1, address.getFirstRow());
            assertEquals(2, address.getLastRow());
            assertEquals(3, address.getFirstColumn());
            assertEquals(4, address.getLastColumn());
        }
        assertEquals(true, dv.getEmptyCellAllowed());
        assertEquals(false, dv.getSuppressDropDownArrow());
        assertEquals(true, dv.getShowErrorBox());
        assertEquals("error-title", dv.getErrorBoxTitle());
        assertEquals("error-text", dv.getErrorBoxText());
        assertEquals(true, dv.getShowPromptBox());
        assertEquals("prompt-title", dv.getPromptBoxTitle());
        assertEquals("prompt-text", dv.getPromptBoxText());

        DataValidationConstraint c = dv.getValidationConstraint();
        assertEquals(ValidationType.ANY, c.getValidationType());
        assertEquals(OperatorType.IGNORED, c.getOperator());
    }
View Full Code Here

        HSSFSheet sheet = wb.createSheet();
        List<HSSFDataValidation> list = sheet.getDataValidations();
        assertEquals(0, list.size());

        DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
        DataValidationConstraint constraint = dataValidationHelper.createIntegerConstraint(OperatorType.BETWEEN, "=A2",
                "=A3");
        CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0);
        DataValidation validation = dataValidationHelper.createValidation(constraint, addressList);
        sheet.addValidationData(validation);
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.usermodel.DataValidationConstraint$ValidationType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.