Search in sources :

Example 1 with DVRecord

use of org.apache.poi.hssf.record.DVRecord in project poi by apache.

the class HSSFSheet method addValidationData.

/**
     * Creates a data validation object
     *
     * @param dataValidation The Data validation object settings
     */
@Override
public void addValidationData(DataValidation dataValidation) {
    if (dataValidation == null) {
        throw new IllegalArgumentException("objValidation must not be null");
    }
    HSSFDataValidation hssfDataValidation = (HSSFDataValidation) dataValidation;
    DataValidityTable dvt = _sheet.getOrCreateDataValidityTable();
    DVRecord dvRecord = hssfDataValidation.createDVRecord(this);
    dvt.addDataValidation(dvRecord);
}
Also used : DVRecord(org.apache.poi.hssf.record.DVRecord) DataValidityTable(org.apache.poi.hssf.record.aggregates.DataValidityTable)

Example 2 with DVRecord

use of org.apache.poi.hssf.record.DVRecord in project poi by apache.

the class HSSFSheet method getDataValidations.

@Override
public List<HSSFDataValidation> getDataValidations() {
    DataValidityTable dvt = _sheet.getOrCreateDataValidityTable();
    final List<HSSFDataValidation> hssfValidations = new ArrayList<HSSFDataValidation>();
    RecordVisitor visitor = new RecordVisitor() {

        private HSSFEvaluationWorkbook book = HSSFEvaluationWorkbook.create(getWorkbook());

        @Override
        public void visitRecord(Record r) {
            if (!(r instanceof DVRecord)) {
                return;
            }
            DVRecord dvRecord = (DVRecord) r;
            CellRangeAddressList regions = dvRecord.getCellRangeAddress().copy();
            DVConstraint constraint = DVConstraint.createDVConstraint(dvRecord, book);
            HSSFDataValidation hssfDataValidation = new HSSFDataValidation(regions, constraint);
            hssfDataValidation.setErrorStyle(dvRecord.getErrorStyle());
            hssfDataValidation.setEmptyCellAllowed(dvRecord.getEmptyCellAllowed());
            hssfDataValidation.setSuppressDropDownArrow(dvRecord.getSuppressDropdownArrow());
            hssfDataValidation.createPromptBox(dvRecord.getPromptTitle(), dvRecord.getPromptText());
            hssfDataValidation.setShowPromptBox(dvRecord.getShowPromptOnCellSelected());
            hssfDataValidation.createErrorBox(dvRecord.getErrorTitle(), dvRecord.getErrorText());
            hssfDataValidation.setShowErrorBox(dvRecord.getShowErrorOnInvalidValue());
            hssfValidations.add(hssfDataValidation);
        }
    };
    dvt.visitContainedRecords(visitor);
    return hssfValidations;
}
Also used : DVRecord(org.apache.poi.hssf.record.DVRecord) ArrayList(java.util.ArrayList) SCLRecord(org.apache.poi.hssf.record.SCLRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) Record(org.apache.poi.hssf.record.Record) HyperlinkRecord(org.apache.poi.hssf.record.HyperlinkRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) NameRecord(org.apache.poi.hssf.record.NameRecord) WSBoolRecord(org.apache.poi.hssf.record.WSBoolRecord) ExtendedFormatRecord(org.apache.poi.hssf.record.ExtendedFormatRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) AutoFilterInfoRecord(org.apache.poi.hssf.record.AutoFilterInfoRecord) DVRecord(org.apache.poi.hssf.record.DVRecord) CellRangeAddressList(org.apache.poi.ss.util.CellRangeAddressList) DataValidityTable(org.apache.poi.hssf.record.aggregates.DataValidityTable) RecordVisitor(org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor)

Aggregations

DVRecord (org.apache.poi.hssf.record.DVRecord)2 DataValidityTable (org.apache.poi.hssf.record.aggregates.DataValidityTable)2 ArrayList (java.util.ArrayList)1 EscherRecord (org.apache.poi.ddf.EscherRecord)1 AutoFilterInfoRecord (org.apache.poi.hssf.record.AutoFilterInfoRecord)1 DimensionsRecord (org.apache.poi.hssf.record.DimensionsRecord)1 DrawingRecord (org.apache.poi.hssf.record.DrawingRecord)1 ExtendedFormatRecord (org.apache.poi.hssf.record.ExtendedFormatRecord)1 HyperlinkRecord (org.apache.poi.hssf.record.HyperlinkRecord)1 NameRecord (org.apache.poi.hssf.record.NameRecord)1 Record (org.apache.poi.hssf.record.Record)1 RowRecord (org.apache.poi.hssf.record.RowRecord)1 SCLRecord (org.apache.poi.hssf.record.SCLRecord)1 WSBoolRecord (org.apache.poi.hssf.record.WSBoolRecord)1 WindowTwoRecord (org.apache.poi.hssf.record.WindowTwoRecord)1 RecordVisitor (org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor)1 CellRangeAddressList (org.apache.poi.ss.util.CellRangeAddressList)1