ValidationType.LIST

I'm using cells for java 2.2.1.0:

validation.setType(ValidationType.LIST);
validation.setOperator(OperatorType.NONE);

will throw an exception: java.lang.IllegalArgumentException: Invalid operator type of the data validation at com.aspose.cells.Validation.setOperator(Unknown Source)
at line validation.setOperator(OperatorType.NONE);

Hi,

When you use List Validation type, you don’t need to specify the operator type, please eliminate the line of code: validation.setOperator(OperatorType.NONE);

See the following sample code:
// Create a workbook object.

Workbook workbook = new Workbook();



// Get the first worksheet.

Worksheet ExcelWorkSheet = workbook.getWorksheets().getSheet(0);



// Add a new worksheet and access it.

Worksheet worksheet2 = workbook.getWorksheets().addSheet();

// Create a range with name in the second worksheet.

NamedRange range = worksheet2.getCells().createNamedRange(“MyRange”,0,4,3,4);



// Fill different cells with data in the range.

range.getCell(0,0).setValue(“Blue”);

range.getCell(1,0).setValue(“Red”);

range.getCell(2,0).setValue(“Green”);

range.getCell(3,0).setValue(“Yellow”);



// Obtain the existing Validations collection.

Validations validations = ExcelWorkSheet.getValidations();



// Create a validation object adding to the collection list.

int index = validations.add();

Validation validation = validations.get(index);



// Set the validation type.

validation.setType(ValidationType.LIST);


// Set the in cell drop down.

validation.setInCellDropDown(true);



// Set the formula1.

validation.setFormula1(“=MyRange”);



// Enable it to show error.

validation.setShowError(true);



// Set the alert type severity level.

validation.setAlertType(ValidationAlertType.STOP);



// Set the error title.

validation.setErrorTitle(“Error”);



// Set the error message.

validation.setErrorMessage(“Please select a color from the list”);



// Specify the validation area of cells.

CellArea area = new CellArea(0,0,4,0);



// Add the Validation area.

validation.addCellArea(area);



// Save the excel file.

workbook.save(“d:\files\validationtypelist.xls”);


For complete reference about validation, please see the document:
http://www.aspose.com/documentation/java-components/aspose.cells-for-java/data-filtering-and-validation.html

Thank you.