https://issues.apache.org/bugzilla/show_bug.cgi?id=51870

             Bug #: 51870
           Summary: Allow HSSFSheet to query existing DataValidation
                    settings [with patch]
           Product: POI
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: HSSF
        AssignedTo: [email protected]
        ReportedBy: [email protected]
    Classification: Unclassified


Created attachment 27567
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27567
Patch.

I need to detect whether a given HSSFSheet already has DataValidation settings
applied.
The DataValidityTable class already has a visitContainedRecords(RecordVisitor)
method, that is currently inaccessible from both HSSFSheet and user code.

The following patch suggests to add a method 

public void visitValidationData(RecordVisitor rv)

to HSSFSheet to iterate through the DataValidation records.
Use it like this:

final RecordVisitor rv = new RecordVisitor() {
  @Override
  public void visitRecord(Record r) {
    if (r instanceof DVRecord){
      final DVRecord dr = (DVRecord) r;
      // So there's the validation
      if (dr.getDataType() == ValidationType.LIST){
           // There is a DROP DOWN list! Use dr.* to examine location and
content.
      }
    }
  }
};
sheet.visitValidationData(rv);



The XSSFSheet already provides a getDataValidations() method,

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to