poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Borut ┼Żagar <borut.za...@gmail.com>
Subject HSSF, protected workbook, data validation
Date Thu, 11 Jun 2009 08:28:04 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message