You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Stuart Owen <so...@cs.manchester.ac.uk> on 2012/09/25 10:47:50 UTC

XmlValueOutOfRangeException using data validations with XSSF

Hi,
     I've encountered a problem using custom Data Validations with XSSF 
sheets. Adding the validation seems to work OK, but afterwards when I 
try getValidations I get an XmlValueOutOfRangeException (full stack 
trace below). The contents of the validation formula doesn't seem to 
matter, and things seem to work correctly if I load a xlsx workbook 
containing custom validations and then try to access them. Here is some 
simplified example code that demonstrates the problem:

         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sheet = wb.createSheet();
         sheet.getDataValidations();    //<-- works

         //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);

         sheet.getDataValidations();    //<-- raised 
XmlValueOutOfRangeException

I also have the same problem when operating on an exisiting workbook 
that contains sheets and cells, I've just simplified the code above.
Is this a bug or am I doing something wrong?

regards,
Stuart Owen

(stack trace below that comes from a test I have created using the above 
code snippet)

org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException: string 
value '' is not a valid enumeration value for ST_DataValidationOperator 
in namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main
     at 
org.apache.xmlbeans.impl.values.JavaStringEnumerationHolderEx.set_text(JavaStringEnumerationHolderEx.java:39)
     at 
org.apache.xmlbeans.impl.values.XmlObjectBase.update_from_wscanon_text(XmlObjectBase.java:1135)
     at 
org.apache.xmlbeans.impl.values.XmlObjectBase.check_dated(XmlObjectBase.java:1274)
     at 
org.apache.xmlbeans.impl.values.JavaStringEnumerationHolderEx.enumValue(JavaStringEnumerationHolderEx.java:60)
     at 
org.apache.xmlbeans.impl.values.XmlObjectBase.getEnumValue(XmlObjectBase.java:1514)
     at 
org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTDataValidationImpl.getOperator(Unknown 
Source)
     at 
org.apache.poi.xssf.usermodel.XSSFDataValidation.getConstraint(XSSFDataValidation.java:250)
     at 
org.apache.poi.xssf.usermodel.XSSFDataValidation.<init>(XSSFDataValidation.java:87)
     at 
org.apache.poi.xssf.usermodel.XSSFSheet.getDataValidations(XSSFSheet.java:3096)
     at ......


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: XmlValueOutOfRangeException using data validations with XSSF

Posted by Stuart Owen <so...@cs.manchester.ac.uk>.
Hi,
     I created a bug report for this issue: 
https://issues.apache.org/bugzilla/show_bug.cgi?id=53965

regards,
Stuart Owen
University of Manchester


On 25/09/2012 09:47, Stuart Owen wrote:
> Hi,
>     I've encountered a problem using custom Data Validations with XSSF 
> sheets. Adding the validation seems to work OK, but afterwards when I 
> try getValidations I get an XmlValueOutOfRangeException (full stack 
> trace below). The contents of the validation formula doesn't seem to 
> matter, and things seem to work correctly if I load a xlsx workbook 
> containing custom validations and then try to access them. Here is 
> some simplified example code that demonstrates the problem:
>
>         XSSFWorkbook wb = new XSSFWorkbook();
>         XSSFSheet sheet = wb.createSheet();
>         sheet.getDataValidations();    //<-- works
>
>         //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);
>
>         sheet.getDataValidations();    //<-- raised 
> XmlValueOutOfRangeException
>
> I also have the same problem when operating on an exisiting workbook 
> that contains sheets and cells, I've just simplified the code above.
> Is this a bug or am I doing something wrong?
>
> regards,
> Stuart Owen
>
> (stack trace below that comes from a test I have created using the 
> above code snippet)
>
> org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException: string 
> value '' is not a valid enumeration value for 
> ST_DataValidationOperator in namespace 
> http://schemas.openxmlformats.org/spreadsheetml/2006/main
>     at 
> org.apache.xmlbeans.impl.values.JavaStringEnumerationHolderEx.set_text(JavaStringEnumerationHolderEx.java:39)
>     at 
> org.apache.xmlbeans.impl.values.XmlObjectBase.update_from_wscanon_text(XmlObjectBase.java:1135)
>     at 
> org.apache.xmlbeans.impl.values.XmlObjectBase.check_dated(XmlObjectBase.java:1274)
>     at 
> org.apache.xmlbeans.impl.values.JavaStringEnumerationHolderEx.enumValue(JavaStringEnumerationHolderEx.java:60)
>     at 
> org.apache.xmlbeans.impl.values.XmlObjectBase.getEnumValue(XmlObjectBase.java:1514)
>     at 
> org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTDataValidationImpl.getOperator(Unknown 
> Source)
>     at 
> org.apache.poi.xssf.usermodel.XSSFDataValidation.getConstraint(XSSFDataValidation.java:250)
>     at 
> org.apache.poi.xssf.usermodel.XSSFDataValidation.<init>(XSSFDataValidation.java:87)
>     at 
> org.apache.poi.xssf.usermodel.XSSFSheet.getDataValidations(XSSFSheet.java:3096)
>     at ......
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org