Search in sources :

Example 1 with DataValidityTable

use of org.apache.poi.hssf.record.aggregates.DataValidityTable in project poi by apache.

the class InternalSheet method getOrCreateDataValidityTable.

public DataValidityTable getOrCreateDataValidityTable() {
    if (_dataValidityTable == null) {
        DataValidityTable result = new DataValidityTable();
        RecordOrderer.addNewSheetRecord(_records, result);
        _dataValidityTable = result;
    }
    return _dataValidityTable;
}
Also used : DataValidityTable(org.apache.poi.hssf.record.aggregates.DataValidityTable)

Example 2 with DataValidityTable

use of org.apache.poi.hssf.record.aggregates.DataValidityTable in project poi by apache.

the class RecordOrderer method findInsertPosForNewCondFormatTable.

/**
	 * Find correct position to add new CFHeader record
	 */
private static int findInsertPosForNewCondFormatTable(List<RecordBase> records) {
    for (int i = records.size() - 2; i >= 0; i--) {
        // -2 to skip EOF record
        Object rb = records.get(i);
        if (rb instanceof MergedCellsTable) {
            return i + 1;
        }
        if (rb instanceof DataValidityTable) {
            continue;
        }
        Record rec = (Record) rb;
        switch(rec.getSid()) {
            case WindowTwoRecord.sid:
            case SCLRecord.sid:
            case PaneRecord.sid:
            case SelectionRecord.sid:
            case UnknownRecord.STANDARDWIDTH_0099:
            // MergedCellsTable usually here
            case UnknownRecord.LABELRANGES_015F:
            case UnknownRecord.PHONETICPR_00EF:
                // ConditionalFormattingTable goes here
                return i + 1;
        }
    }
    throw new RuntimeException("Did not find Window2 record");
}
Also used : MergedCellsTable(org.apache.poi.hssf.record.aggregates.MergedCellsTable) DrawingSelectionRecord(org.apache.poi.hssf.record.DrawingSelectionRecord) GutsRecord(org.apache.poi.hssf.record.GutsRecord) UnknownRecord(org.apache.poi.hssf.record.UnknownRecord) ArrayRecord(org.apache.poi.hssf.record.ArrayRecord) DefaultColWidthRecord(org.apache.poi.hssf.record.DefaultColWidthRecord) DateWindow1904Record(org.apache.poi.hssf.record.DateWindow1904Record) DefaultRowHeightRecord(org.apache.poi.hssf.record.DefaultRowHeightRecord) GridsetRecord(org.apache.poi.hssf.record.GridsetRecord) SCLRecord(org.apache.poi.hssf.record.SCLRecord) DrawingRecord(org.apache.poi.hssf.record.DrawingRecord) BoolErrRecord(org.apache.poi.hssf.record.BoolErrRecord) Record(org.apache.poi.hssf.record.Record) HyperlinkRecord(org.apache.poi.hssf.record.HyperlinkRecord) ObjRecord(org.apache.poi.hssf.record.ObjRecord) EOFRecord(org.apache.poi.hssf.record.EOFRecord) PrintHeadersRecord(org.apache.poi.hssf.record.PrintHeadersRecord) RefModeRecord(org.apache.poi.hssf.record.RefModeRecord) PrecisionRecord(org.apache.poi.hssf.record.PrecisionRecord) RowRecord(org.apache.poi.hssf.record.RowRecord) SharedFormulaRecord(org.apache.poi.hssf.record.SharedFormulaRecord) CalcCountRecord(org.apache.poi.hssf.record.CalcCountRecord) ColumnInfoRecord(org.apache.poi.hssf.record.ColumnInfoRecord) WindowTwoRecord(org.apache.poi.hssf.record.WindowTwoRecord) PrintGridlinesRecord(org.apache.poi.hssf.record.PrintGridlinesRecord) IterationRecord(org.apache.poi.hssf.record.IterationRecord) CalcModeRecord(org.apache.poi.hssf.record.CalcModeRecord) SelectionRecord(org.apache.poi.hssf.record.SelectionRecord) TextObjectRecord(org.apache.poi.hssf.record.TextObjectRecord) LabelSSTRecord(org.apache.poi.hssf.record.LabelSSTRecord) RKRecord(org.apache.poi.hssf.record.RKRecord) IndexRecord(org.apache.poi.hssf.record.IndexRecord) BOFRecord(org.apache.poi.hssf.record.BOFRecord) LabelRecord(org.apache.poi.hssf.record.LabelRecord) DVALRecord(org.apache.poi.hssf.record.DVALRecord) WindowOneRecord(org.apache.poi.hssf.record.WindowOneRecord) DeltaRecord(org.apache.poi.hssf.record.DeltaRecord) PaneRecord(org.apache.poi.hssf.record.PaneRecord) NumberRecord(org.apache.poi.hssf.record.NumberRecord) FeatRecord(org.apache.poi.hssf.record.FeatRecord) ViewDefinitionRecord(org.apache.poi.hssf.record.pivottable.ViewDefinitionRecord) SaveRecalcRecord(org.apache.poi.hssf.record.SaveRecalcRecord) TableRecord(org.apache.poi.hssf.record.TableRecord) UncalcedRecord(org.apache.poi.hssf.record.UncalcedRecord) DimensionsRecord(org.apache.poi.hssf.record.DimensionsRecord) BlankRecord(org.apache.poi.hssf.record.BlankRecord) FormulaRecord(org.apache.poi.hssf.record.FormulaRecord) DataValidityTable(org.apache.poi.hssf.record.aggregates.DataValidityTable)

Example 3 with DataValidityTable

use of org.apache.poi.hssf.record.aggregates.DataValidityTable 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 4 with DataValidityTable

use of org.apache.poi.hssf.record.aggregates.DataValidityTable 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

DataValidityTable (org.apache.poi.hssf.record.aggregates.DataValidityTable)4 DVRecord (org.apache.poi.hssf.record.DVRecord)2 DimensionsRecord (org.apache.poi.hssf.record.DimensionsRecord)2 DrawingRecord (org.apache.poi.hssf.record.DrawingRecord)2 HyperlinkRecord (org.apache.poi.hssf.record.HyperlinkRecord)2 Record (org.apache.poi.hssf.record.Record)2 RowRecord (org.apache.poi.hssf.record.RowRecord)2 SCLRecord (org.apache.poi.hssf.record.SCLRecord)2 WindowTwoRecord (org.apache.poi.hssf.record.WindowTwoRecord)2 ArrayList (java.util.ArrayList)1 EscherRecord (org.apache.poi.ddf.EscherRecord)1 ArrayRecord (org.apache.poi.hssf.record.ArrayRecord)1 AutoFilterInfoRecord (org.apache.poi.hssf.record.AutoFilterInfoRecord)1 BOFRecord (org.apache.poi.hssf.record.BOFRecord)1 BlankRecord (org.apache.poi.hssf.record.BlankRecord)1 BoolErrRecord (org.apache.poi.hssf.record.BoolErrRecord)1 CalcCountRecord (org.apache.poi.hssf.record.CalcCountRecord)1 CalcModeRecord (org.apache.poi.hssf.record.CalcModeRecord)1 ColumnInfoRecord (org.apache.poi.hssf.record.ColumnInfoRecord)1 DVALRecord (org.apache.poi.hssf.record.DVALRecord)1