Example usage for org.apache.poi.ss.usermodel DataValidation setEmptyCellAllowed

List of usage examples for org.apache.poi.ss.usermodel DataValidation setEmptyCellAllowed

Introduction

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

Prototype

public abstract void setEmptyCellAllowed(boolean allowed);

Source Link

Document

Sets if this object allows empty as a valid value

Usage

From source file:com.asakusafw.testdata.generator.excel.SheetEditor.java

License:Apache License

private void setExplicitListConstraint(Sheet sheet, String[] list, int firstRow, int firstCol, 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);
}

From source file:de.jlo.talendcomp.excel.SpreadsheetOutput.java

License:Apache License

private void createNewAppendingDataValidationAsCopy(Sheet sheet, DataValidation originalDv, int lastRowIndex) {
    CellRangeAddressList originalAl = originalDv.getRegions();
    CellRangeAddressList appendingAddressList = createNewAppendingCellRangeAddressList(originalAl,
            lastRowIndex);//  www  .java 2s. c om
    DataValidationHelper dvHelper = sheet.getDataValidationHelper();
    DataValidation newValidation = dvHelper.createValidation(originalDv.getValidationConstraint(),
            appendingAddressList);
    newValidation.setSuppressDropDownArrow(originalDv.getSuppressDropDownArrow());
    newValidation.setShowErrorBox(originalDv.getShowErrorBox());
    newValidation.setShowPromptBox(originalDv.getShowPromptBox());
    newValidation.setEmptyCellAllowed(originalDv.getEmptyCellAllowed());
    newValidation.setErrorStyle(originalDv.getErrorStyle());
    String promptBoxText = originalDv.getPromptBoxText();
    String promptBoxTitle = originalDv.getPromptBoxTitle();
    String errorBoxText = originalDv.getErrorBoxText();
    String errorBoxTitle = originalDv.getErrorBoxTitle();
    if (promptBoxTitle != null && promptBoxText != null) {
        newValidation.createPromptBox(promptBoxTitle, promptBoxText);
    }
    if (errorBoxTitle != null && errorBoxText != null) {
        newValidation.createErrorBox(errorBoxTitle, errorBoxText);
    }
    sheet.addValidationData(newValidation);
}

From source file:edu.casetools.rcase.extensions.excel.control.Exporter.java

License:Open Source License

private DataValidation createExcel2007CellStyle(Sheet sheet, String[] possibleValues,
        CellRangeAddressList addressList) {
    DataValidation validation;
    DataValidationConstraint constraint;
    DataValidationHelper validationHelper;
    validationHelper = new XSSFDataValidationHelper((XSSFSheet) sheet);

    constraint = validationHelper.createExplicitListConstraint(possibleValues);
    validation = validationHelper.createValidation(constraint, addressList);
    validation.setEmptyCellAllowed(false);
    validation.setShowErrorBox(true);//w w w  .  ja v a  2 s  .  c om
    validation.setErrorStyle(0);
    return validation;
}