<changes>
<release version="3.9-beta1" date="2012-??-??">
+ <action dev="poi-developers" type="fix">53965 - Fixed XmlValueOutOfRangeExceptio calling getDataValidations for custom validations with XSSFSheet </action>
<action dev="poi-developers" type="fix">53974 - Avoid NPE when constructing HSSFWorbook on Google App Engine</action>
<action dev="poi-developers" type="fix">53568 - Fixed null returned by XSSFPicture.getPictureData()</action>
<action dev="poi-developers" type="fix">53950 - fixed setForceFormulaRecalculation to reset workbook-level "manual" flag</action>
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDataValidation;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataValidationOperator;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataValidationType;
/**
}
if (validationType!=ValidationType.ANY && validationType!=ValidationType.LIST) {
- newDataValidation.setOperator(XSSFDataValidation.operatorTypeMappings.get(constraint.getOperator()));
+ STDataValidationOperator.Enum op = XSSFDataValidation.operatorTypeMappings.get(constraint.getOperator());
+ if(op != null) {
+ newDataValidation.setOperator(op);
+ }
if (constraint.getFormula1() != null) {
newDataValidation.setFormula1(constraint.getFormula1());
}
==================================================================== */
package org.apache.poi.xssf.usermodel;
+import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.util.List;
validation.createPromptBox("Prompt", "Enter some value");
validation.setSuppressDropDownArrow(yesNo);
}
+
+ public void test53965() throws Exception {
+
+ XSSFWorkbook wb = new XSSFWorkbook();
+ XSSFSheet sheet = wb.createSheet();
+ List<XSSFDataValidation> lst = sheet.getDataValidations(); //<-- works
+ assertEquals(0, lst.size());
+
+ //create the cell that will have the validation applied
+ sheet.createRow(0).createCell(0);
+
+ DataValidationHelper dataValidationHelper = sheet.getDataValidationHelper();
+ DataValidationConstraint constraint = dataValidationHelper.createCustomConstraint("SUM($A$1:$A$1) <= 3500");
+ CellRangeAddressList addressList = new CellRangeAddressList(0, 0, 0, 0);
+ DataValidation validation = dataValidationHelper.createValidation(constraint, addressList);
+ sheet.addValidationData(validation);
+
+ // this line caused XmlValueOutOfRangeException , see Bugzilla 3965
+ lst = sheet.getDataValidations();
+ assertEquals(1, lst.size());
+ }
}