Forgive me if this is a stupid question but what order are you doing the
operations in? Are you adding the validation and then protecting the sheet
or protecting the sheet and then adding the validation?

I have no idea if it matters at all but it could be that, if you are
protecting the sheet and then adding the validation, that this is the source
of the problem.

Yours

Mark B


Borut Žagar wrote:
> 
> Hi!
> 
> I am using POI final 3.2, and I am creating a worksheet which I want it to
> be
> protected (certain cells cannot be edited).
> 
> But I am getting an exception when adding a data validation to the
> worksheet.
> The exception is:
> 
> java.lang.IllegalStateException: Unexpected
> (org.apache.poi.hssf.record.PasswordRecord) while looking for DV Table
> insert pos
>     at
> org.apache.poi.hssf.model.RecordOrderer.findDataValidationTableInsertPos(RecordOrderer.java:240)
>     at
> org.apache.poi.hssf.model.RecordOrderer.findSheetInsertPos(RecordOrderer.java:95)
>     at
> org.apache.poi.hssf.model.RecordOrderer.addNewSheetRecord(RecordOrderer.java:89)
>     at
> org.apache.poi.hssf.model.Sheet.getOrCreateDataValidityTable(Sheet.java:1752)
>     at
> org.apache.poi.hssf.usermodel.HSSFSheet.addValidationData(HSSFSheet.java:369)
>     at
> com.cmpny.product.bl.pr.PremiumsImporterExporterBL.addInputTypeDropdown(PremiumsImporterExporterBL.java:163)
> 
> 
> The code for adding data validation object is:
> 
> CellRangeAddressList cral = new CellRangeAddressList(1, 1, 1, 1);
> HSSFDataValidation dataValidation =
>     new HSSFDataValidation(cral,
> DVConstraint.createExplicitListConstraint(new
> String[] {"one", "two"}));
> dataValidation.setEmptyCellAllowed(false);
> dataValidation.setSuppressDropDownArrow(false);
> dataValidation.setShowPromptBox(false);
> dataValidation.createErrorBox("Wrong value", "Please select from list.");
> wb.getCurrentSheet().addValidationData(dataValidation);
> 
> 
> If I remove worksheet protection or remove adding of data validation
> object
> to
> workbook it all works fine so it seems that both together are not working.
> 
> Regards, Borut
> 
> 

-- 
View this message in context: 
http://www.nabble.com/HSSF%2C-protected-workbook%2C-data-validation-tp23977349p23987275.html
Sent from the POI - User mailing list archive at Nabble.com.


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

Reply via email to